[Asterisk-code-review] func_json: Adds JSON_DECODE function (asterisk[master])

Kevin Harwell asteriskteam at digium.com
Thu Nov 18 09:12:33 CST 2021


Attention is currently required from: N A, Joshua Colp.
Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16634 )

Change subject: func_json: Adds JSON_DECODE function
......................................................................


Patch Set 7:

(1 comment)

File funcs/func_json.c:

https://gerrit.asterisk.org/c/asterisk/+/16634/comment/a83e7bda_d493a787 
PS6, Line 109: 	result = ast_json_object_string_get(json, args.key);
> Hmm... is this related to also having ast_json_object_integer_get? […]
Yes related to ast_json_object_integer_get, and other types. The key itself will always be a string, but the associated value could be any type (string, int, array, object, real, true/false, and null).

If you know, and/or only care about string values then what you have here is fine. But it'd be better to handle all values. At the very least output a warning for unsupported types.

You can just retrieve the value as a json_object, and then check its type with 'ast_json_typeof'. Also it might be better to iterate ('ast_json_iter') over a given object, check each value type and if it's another object recurse and search that object too for the key. Just some ideas. More info can be found in json.h.



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16634
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Iea60c49a7358dfdc2db60803cdc9a742f808ba2c
Gerrit-Change-Number: 16634
Gerrit-PatchSet: 7
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Attention: N A <mail at interlinked.x10host.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Comment-Date: Thu, 18 Nov 2021 15:12:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: N A <mail at interlinked.x10host.com>
Comment-In-Reply-To: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211118/bbb7ffeb/attachment-0001.html>


More information about the asterisk-code-review mailing list