Refactor json_pack()
* Implement a "scanner" that reads the format string, maintaining state * Split json_vnpack() to three separate functions for packing objects, arrays and simple values. This makes it more clear what is being packed, and the object and array structures become more evident. * Make the skipping of ignored character simpler, i.e. skip ':' and ',' independent of their context This patch shaves around 80 lines of code from the original implementation.
This commit is contained in:
@@ -191,7 +191,7 @@ int main()
|
||||
|
||||
if(json_pack(&error, "{ s: {}, s:[ii{} }", "foo", "bar", 12, 13))
|
||||
fail("json_pack failed to catch missing ]");
|
||||
if(error.line != 1 || error.column != 13)
|
||||
if(error.line != 1 || error.column != 19)
|
||||
fail("json_pack didn't get the error coordinates right!");
|
||||
|
||||
if(json_pack(&error, "[[[[[ [[[[[ [[[[ }]]]] ]]]] ]]]]]"))
|
||||
|
||||
Reference in New Issue
Block a user