Add a json_object_from_fd_ex() function, to allow the max nesting depth to be specified.

This commit is contained in:
Eric Haszlakiewicz
2019-11-10 00:12:27 -05:00
parent ac26ea9c5b
commit baed9983b3
6 changed files with 94 additions and 7 deletions

View File

@@ -1,4 +1,7 @@
OK: json_object_from_fd(./valid.json)={ "foo": 123 }
OK: json_object_from_fd(valid.json)={ "foo": 123 }
OK: json_object_from_fd_ex(valid_nested.json, 20)={ "foo": 123, "obj2": { "obj3": { "obj4": { "foo": 999 } } } }
OK: correctly unable to parse contents of valid_nested.json with low max depth: json_tokener_parse_ex failed: nesting too deep
OK: json_object_from_file(./not_present.json) correctly returned NULL: json_object_from_file: error opening file ./not_present.json: ERRNO=ENOENT
OK: json_object_from_fd(closed_fd), expecting NULL, EBADF, got:NULL, json_object_from_fd: error reading fd 10: ERRNO=EBADF