]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
json.h: Add ast_json_object_real_get.
authorNaveen Albert <asterisk@phreaknet.org>
Fri, 16 Dec 2022 18:25:52 +0000 (18:25 +0000)
committerGeorge Joseph <gjoseph@digium.com>
Wed, 4 Jan 2023 11:52:07 +0000 (05:52 -0600)
json.h contains macros to get a string and an integer
from a JSON object. However, the macro to do this for
JSON reals is missing. This adds that.

ASTERISK-30361 #close

Change-Id: I8d0e28d763febf27b05801cdc83b73282aa6ee7a

include/asterisk/json.h

index 9c42c3f13dffbe2e687ab53fa2006103d91a12e7..5edc3a9754ebc5952ff05d5ecebcca9ee523c942 100644 (file)
@@ -592,6 +592,15 @@ struct ast_json *ast_json_object_get(struct ast_json *object, const char *key);
  */
 #define ast_json_object_integer_get(object, key) ast_json_integer_get(ast_json_object_get(object, key))
 
+/*!
+ * \brief Get a double field from a JSON object.
+ * \param object JSON object.
+ * \param key Key of double field to look up.
+ * \return Value of a JSON double.
+ * \retval 0 if \a real is not a JSON real number.
+ */
+#define ast_json_object_real_get(object, key) ast_json_real_get(ast_json_object_get(object, key))
+
 /*!
  * \brief Set a field in a JSON object.
  * \since 12.0.0