Commit Graph

17 Commits

Author SHA1 Message Date
Petri Lehtinen
df307f1bc3 Report errors from lexical and stream level in parser
Before, only the syntax level (parse_*) was able to set the error
string. This patch fixes the situation so that lexical (lex_*) and
stream (stream_*) levels can report detailed error messages.

Also, instead of 0, EOF is now returned by stream on error.
2009-07-14 00:24:39 +03:00
Petri Lehtinen
902bcdaa5e Decode and check for correct UTF-8
All strings (decoded JSON text, the argument of json_string(), the key
argument of json_object_set()) are checked for valid UTF-8.
2009-07-13 23:38:01 +03:00
Petri Lehtinen
625f50f916 Streamify the loader
It's no longer needed to load the whole input into a string and then
parse from the string. Instead, the input is read as needed from
a string or file.
2009-07-13 21:45:16 +03:00
Petri Lehtinen
4c414bdd6d Get rid of json_dumpfd and json_loadfd
fdopen() makes supporting separate API for file descriptors useless.
Supporting fd's also makes Jansson less portable.
2009-07-13 21:45:16 +03:00
Petri Lehtinen
1b67edb54d Little clean-up in parser
Before, json_loads checked for '[' or '{' at the beginning. Now
there's a dedicated function for that: parse_json(). Also rename
parse() to parse_value().
2009-07-13 21:45:16 +03:00
Petri Lehtinen
287ec3f9da Unify naming in parser
No functional changes.
2009-07-13 21:45:16 +03:00
Petri Lehtinen
13c7ad3219 Make the lexer not depend on locale
... by not using isalpha() and isspace(). While at it, fix some other
minor things.
2009-07-13 21:45:11 +03:00
Petri Lehtinen
f9c2a113bb Fix number tokenizer 2009-07-04 22:04:32 +03:00
Petri Lehtinen
b724c2b122 Separate integers and real numbers 2009-07-04 13:19:25 +03:00
Petri Lehtinen
b1fe723a7f Fix json_loadf and json_loadfd with empty input
Nothing was appended to strbuffer, so the buffer was left empty. An
empty strbuffer is not an empty string but NULL, so the result was a
segfault.

This patch fixes the problem by initializing strbuffer to an empty
string.
2009-06-30 13:55:20 +03:00
Petri Lehtinen
dc9b954b62 Print correct error message on premature end of array 2009-06-30 13:55:20 +03:00
Petri Lehtinen
ae5ed3ff70 Fix json_set_error
Both error->line and error->text were set improperly, sigh.
2009-06-15 22:30:52 +03:00
Petri Lehtinen
7dc6cfd9cc Fix a few memory leaks in json_parse_object() 2009-06-15 13:53:53 +03:00
Petri Lehtinen
d135a80e07 Implement json_load, json_loadf and json_loadfd 2009-06-15 13:53:50 +03:00
Petri Lehtinen
fdcf28b667 Refactor error reporting 2009-05-13 22:25:34 +03:00
Petri Lehtinen
514bbeaf7f Parse an empty object correctly 2009-05-12 21:44:45 +03:00
Petri Lehtinen
17a69c2d66 Initial import 2009-05-12 21:44:01 +03:00