Commit Graph

1118 Commits

Author SHA1 Message Date
Eric Fischer
a2fd84c0a3 Fix more memory leaks 2014-02-08 10:21:53 -08:00
Eric Fischer
b6f079fea8 Additional rationale 2014-02-08 10:10:55 -08:00
Eric Fischer
c6077f7e54 Fix memory leaks from errors while reading strings or numbers 2014-02-08 10:04:23 -08:00
Eric Fischer
391db023e0 Talk about error cleanup in README 2014-02-08 09:57:55 -08:00
Eric Fischer
5a01013642 Make sure the root pointer is null for errors at the top level 2014-02-08 09:41:49 -08:00
Eric Fischer
b72bb6f1f4 Clean up after errors and fix related bugs:
It was freeing the wrong object when there was an error
attaching an object to its parent!

Don't crash when printing null (partially read) hash values.
2014-02-08 09:31:49 -08:00
Eric Fischer
5e6fa6f8dc Remember to deallocate the parser 2014-02-08 00:42:28 -08:00
Eric Fischer
54f637a9a8 More documentation of object internals 2014-02-07 18:11:36 -08:00
Eric Fischer
9d31e8a05e Slightly less wordy name for reading JSON with separators 2014-02-07 18:01:18 -08:00
Eric Fischer
39f9ff3f04 Make streaming formatting consistent 2014-02-07 17:14:39 -08:00
Eric Fischer
9979c70b1f Add the whole-tree reader 2014-02-07 17:02:33 -08:00
Eric Fischer
0fd66048c8 Get rid of root node to simplify. Walk the tree if you need it. 2014-02-07 16:56:38 -08:00
Eric Fischer
e99c037be3 Add header dependency 2014-02-07 16:53:02 -08:00
Eric Fischer
1cbf8a813e Match documented function names 2014-02-07 16:49:52 -08:00
Eric Fischer
45049fb874 More documentation 2014-02-07 16:48:06 -08:00
Eric Fischer
8278580336 Begin README 2014-02-07 16:25:54 -08:00
Eric Fischer
a7e26262ea Expose interface for arbitrary reader functions 2014-02-07 16:23:03 -08:00
Eric Fischer
4a14e09457 Clarify what types are used where 2014-02-07 16:09:05 -08:00
Eric Fischer
fee27e1353 Add a callback interface for non-closing punctuation 2014-02-07 15:51:46 -08:00
Eric Fischer
f67e97cd08 Work out more details of how json_free() needs to work.
The idea is that you can free any element once you are
done with it, even if it is part of an array or hash that
isn't completely read yet.

Removing array elements is reasonably well defined because
nothing else depends on them. Removing a hash key or value
causes it to be replaced by a null unless the other side of
the component has already been nulled out, in which case
the whole pair is removed.
2014-02-06 22:45:40 -08:00
Eric Fischer
f0f73c6dd1 Keep track of the root of the parse tree for the caller 2014-02-06 21:06:27 -08:00
Eric Fischer
415193ad8e Remove old state resetting 2014-02-06 21:05:46 -08:00
Eric Fischer
69a5ca0bb9 Include filename in error output 2014-02-06 20:51:15 -08:00
Eric Fischer
9d4ee102b4 Forgot to initialize the error to NULL 2014-02-06 20:49:48 -08:00
Eric Fischer
a74444af28 Track line number for error reports 2014-02-06 20:44:39 -08:00
Eric Fischer
46120e84c4 Remember to check for missing commas 2014-02-06 20:31:31 -08:00
Eric Fischer
e22b154ecc Add an input form that parses JSON from a string 2014-02-06 19:27:21 -08:00
Eric Fischer
ed079e37a9 Add a reader abstraction 2014-02-06 19:22:37 -08:00
Eric Fischer
979b9243d8 A container object makes the state transitions more straightforward
And should make it possible to free an object that has just been read
and still know what the next state will be, importantly.
2014-02-06 18:56:22 -08:00
Eric Fischer
55510cac04 Start adding free logic 2014-02-06 17:58:23 -08:00
Eric Fischer
e9d2c94f93 Pass along the string length instead of just null-terminating 2014-02-06 13:28:35 -08:00
Eric Fischer
1a7b4189bf Detect a lack of digits in the exponent for a number 2014-02-06 13:26:56 -08:00
Eric Fischer
55692cb27c Treat unclosed containers at EOF as an error after all 2014-02-06 13:20:56 -08:00
Eric Fischer
6449e817b6 Detect attempts to attach an element to a non-container parent.
Maybe there is a better name for this. The typical case is adjacent
tokens not separated by a comma.
2014-02-06 12:51:32 -08:00
Eric Fischer
ad2843d65b Be consistent about EOF handling around whitespace 2014-02-06 12:31:12 -08:00
Eric Fischer
f76bcab825 Detect misplaced comma within hash 2014-02-06 12:25:59 -08:00
Eric Fischer
948584126a Detect trailing commas and colons inside arrays and hashes. 2014-02-06 12:19:33 -08:00
Eric Fischer
42283ece0b More sensible way of passing errors back to caller 2014-02-06 12:13:23 -08:00
Eric Fischer
f8465828e5 Maybe the right way to handle empty arrays?
The previous check for the array length being 0 didn't work
for the case of an array that contains only an empty array.

The tricky part is that the current node is the array when
the array has just begun or just after a comma, but also
when the completed array has been passed off to the caller.
2014-02-06 00:30:25 -08:00
Eric Fischer
68e0784cc3 At least don't talk about allocation sizes in the public API 2014-02-05 23:35:35 -08:00
Eric Fischer
d630aa917e Put arrays in order by getting rid of the linked lists.
Resizing is ugly, but less ugly than backwards arrays.
2014-02-05 23:18:27 -08:00
Eric Fischer
879f9126b3 Name the types in the order the JSON spec names them in 2014-02-05 22:40:35 -08:00
Eric Fischer
c69e595e4e Do escaping in output strings 2014-02-05 22:34:47 -08:00
Eric Fischer
9299ef2ecb Handle empty arrays and hashes. Detect non-string hash keys. 2014-02-05 22:13:03 -08:00
Eric Fischer
71981fc49e Add Makefile 2014-02-05 22:04:58 -08:00
Eric Fischer
7641459278 Handle named files, not just standard input 2014-02-05 22:00:52 -08:00
Eric Fischer
264abd48de Fix crash with comma or colon at the top level. 2014-02-05 21:52:39 -08:00
Eric Fischer
e7184989ec Handle \u escapes in strings 2014-02-05 21:42:49 -08:00
Eric Fischer
4506a85e6b Add comments 2014-02-05 21:34:17 -08:00
Eric Fischer
95410dbf33 Fix logic error that broke top-level hashes 2014-02-05 21:29:40 -08:00