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

Kevin Harwell asteriskteam at digium.com
Thu Nov 18 12:34:03 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 11:

(3 comments)

File funcs/func_json.c:

https://gerrit.asterisk.org/c/asterisk/+/16634/comment/05b118af_9b43f0cd 
PS6, Line 109: 	result = ast_json_object_string_get(json, args.key);
> I see how it would be done for string and int, but what about array or any of the other stuff? Not s […]
It'd either fail for those cases, or one could 'stringify' them somehow but chances are the latter is not what someone would want/expect.

Perhaps an api call can be added later if the need arises again.

Another option I just thought, is you might be able to just call 'ast_json_dump_string'. I assume if you pass that function, say an integer object it'll just convert the integer to string. That however has the overhead of allocating a new string.


File funcs/func_json.c:

https://gerrit.asterisk.org/c/asterisk/+/16634/comment/3381f09c_ca4a4103 
PS11, Line 119: 			result = ast_json_object_string_get(json, args.key);
You've already retrieved the value above in 'jsonval', so you don't have to look it up by key again here if you don't want. You can just call 'ast_json_string_get(jsonval)'.


https://gerrit.asterisk.org/c/asterisk/+/16634/comment/411cca71_ca38b5a1 
PS11, Line 123: 			r = ast_json_object_integer_get(json, args.key);
Similar for here. You can just call 'ast_json_integer_get(jsonval)' without a second lookup.



-- 
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: 11
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 18:34:03 +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/0be79ad6/attachment.html>


More information about the asterisk-code-review mailing list