>From my previous experience - I'd like to say this lib is better than libjson-c.
Last night I pushed an updated json module to branch mgw/json. It has significant improvements over the previous version, including:* A way to access nested elements, using a subset of JSONPath.* The ability to loop over arrays
Note that there is a change in the external dependency from libjson-c to libjansson.Matthew WilliamsDocumentation:JSON ModuleJoe HillenbrandEdited byMatthew WilliamsCopyright © 2013 Flowroute LLC (flowroute.com)__________________________________________________________________Table of Contents1. Admin Guide1. Overview2. Dependencies2.1. Kamailio Modules2.2. External Libraries or Applications3. Parameters3.1.4. Functions4.1. json_path_get(json_string, json_path, destination)4.2. json_array_size(json_string, json_path, destination)4.3. json_get_field(json_string, field_name, destination)List of Examples1.1. json_path_get usage1.2. json_array_size usage1.3. json_get_field usageChapter 1. Admin GuideTable of Contents1. Overview2. Dependencies2.1. Kamailio Modules2.2. External Libraries or Applications3. Parameters3.1.4. Functions4.1. json_path_get(json_string, json_path, destination)4.2. json_array_size(json_string, json_path, destination)4.3. json_get_field(json_string, field_name, destination)1. OverviewThis module provides operations on json strings.2. Dependencies2.1. Kamailio Modules2.2. External Libraries or Applications2.1. Kamailio ModulesThe following modules must be loaded before this module:* None2.2. External Libraries or ApplicationsThe following libraries or applications must be installed beforerunning Kamailio with this module loaded:* jansson (http://www.digip.org/jansson/), tested with: 2.2+3. Parameters3.1.None4. Functions4.1. json_path_get(json_string, json_path, destination)4.2. json_array_size(json_string, json_path, destination)4.3. json_get_field(json_string, field_name, destination)4.1. json_path_get(json_string, json_path, destination)Copy the value at the path from json object 'json_string' and store itin pvar 'destination'.The path string supports dot delimited notation (e.g. foo.bar.baz),array notation (e.g. list[0]), or a combination of the two (e.g.foo.bar[0][1].baz).The function can put a string, integer, null, or new json string intodestination.Example 1.1. json_path_get usage...json_path_get($var(myjson), "inner.deep.num", "$var(n)");xlog("foo is $var(n)");...4.2. json_array_size(json_string, json_path, destination)Puts size of the array in 'json_string' at 'json_path' into the pvar'destination'.This is particularly useful for looping through an array. See example.Example 1.2. json_array_size usage...$var(array) = "{\"loopme\":[0,1,2,3,4,5]}";$var(count) = 0;json_array_size($var(array), "loopme", "$var(size)");while($var(count) < $var(size)) {json_path_get($var(array), "loopme[$var(count)]", "$var(v)");xlog("loopme[$var(count)] == $var(v)\n");$var(count) = $var(count) + 1;}...4.3. json_get_field(json_string, field_name, destination)Copy field 'field_name' from json object 'json_string' and store it inpvar 'destination'.This function is deprecated but kept for backwards compatibility. Rightnow it is just a wrapper around json_path_get, and its functionality isthe same.Example 1.3. json_get_field usage...json_get_field("{'foo':'bar'}", "foo", "$var(foo)");xlog("foo is $var(foo)");...
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev