@@ -174,7 +174,11 @@ static int parse_node(char **key, char *currentkey, char *nestchar, int count, s
174
174
previouskey = currentkey ;
175
175
currentkey = strsep (key , nestchar ); /* retrieve the desired index */
176
176
ast_debug (1 , "Recursing on object (key was '%s' and is now '%s')\n" , previouskey , currentkey );
177
- if (parse_node (key , currentkey , nestchar , count , ast_json_object_get (jsonval , currentkey ), buf , len , depth )) { /* recurse on this node */
177
+ if (!currentkey ) { /* this is the end, so just dump the object */
178
+ char * result2 = ast_json_dump_string (jsonval );
179
+ ast_copy_string (buf , result2 , len );
180
+ ast_json_free (result2 );
181
+ } else if (parse_node (key , currentkey , nestchar , count , ast_json_object_get (jsonval , currentkey ), buf , len , depth )) { /* recurse on this node */
178
182
return -1 ;
179
183
}
180
184
}
@@ -305,6 +309,7 @@ AST_TEST_DEFINE(test_JSON_DECODE)
305
309
{"{ \"path\": { \"to\": { \"arr\": [ {\"name\": \"John Smith\", \"phone\": \"123\"}, {\"name\": \"Jane Doe\", \"phone\": \"234\"} ] } } }" , ",c" , "path.to.arr.0.name" , "John Smith" },
306
310
{"{ \"path\": { \"to\": { \"arr\": [ {\"name\": 1, \"phone\": 123}, {\"name\": 2, \"phone\": 234} ] } } }" , ",c" , "path.to.arr.0.name" , "1" },
307
311
{"{ \"path\": { \"to\": { \"arr\": [ {\"name\": [ \"item11\", \"item12\" ], \"phone\": [ \"item13\", \"item14\" ]}, {\"name\": [ \"item15\", \"item16\" ], \"phone\": [ \"item17\", \"item18\" ]} ] } } }" , ",c" , "path.to.arr.0.name.1" , "item12" },
312
+ {"{ \"startId\": \"foobar\", \"abcd\": { \"id\": \"abcd\", \"type\": \"EXT\" }, \"bcde\": { \"id\": \"bcde\", \"type\": \"CONDITION\" }, \"defg\": { \"id\": \"defg\", \"type\": \"EXT\" }, \"efgh\": { \"id\": \"efgh\", \"type\": \"VOICEMAIL\" } }" , "" , "bcde" , "{\"id\":\"bcde\",\"type\":\"CONDITION\"}" },
308
313
};
309
314
310
315
switch (cmd ) {
0 commit comments