Petri Lehtinen
bfac1972e2
Add a flags parameter to all decoding functions for future needs
...
As of now, the parameter is unused, but may be needed in the future.
I'm adding it now so that in the future both API and ABI remain
backwards compatible as long as possible.
This is a backwards incompatible change.
2010-08-14 17:28:09 +03:00
Petri Lehtinen
ffbab6fedd
Change the underlying type of JSON integer from long to json_int_t
...
json_int_t is typedef'd to long long if it's supported, or long
otherwise. There's also some supporting things, like the
JSON_INTEGER_FORMAT macro that expands to the printf() conversion
specifier that corresponds to json_int_t's actual type.
This is a backwards incompatible change.
2010-08-13 22:07:20 +03:00
Petri Lehtinen
014c49c285
Change JSON integer's underlying type from int to long
...
This is a backwards incompatible change.
2010-08-10 21:45:18 +03:00
Petri Lehtinen
f9475f9577
load.c: Make stream_init() static
2010-05-07 07:35:11 +03:00
Petri Lehtinen
bb89a5d4d3
Estimate real number underflows with 0.0
...
Earlier it was a decoding error.
2010-03-26 21:59:56 +02:00
Petri Lehtinen
286823227c
Make int32_t available on all systems
...
Use AC_TYPE_INT32_T and include inttypes.h (if it exists) instead of
stdint.h for maximum portability.
2010-02-06 21:11:41 +02:00
Petri Lehtinen
08dc8d9baf
Add year 2010 to copyright notices
2010-02-02 21:26:11 +02:00
Petri Lehtinen
e7a5dc58e6
Merge branch '1.1'
...
Conflicts:
configure.ac
doc/conf.py
2009-12-21 12:52:25 +02:00
Petri Lehtinen
50031440a3
Implement JSON_ENSURE_ASCII encoding flag
...
With this flag, all Unicode characters outside the ASCII range are
escaped.
2009-12-05 22:55:30 +02:00
Petri Lehtinen
d67aeb9739
Use int32_t instead of plain int with Unicode code points
...
On some architectures, int just isn't big enough to hold all Unicode
code points.
2009-12-02 23:53:54 +02:00
Petri Lehtinen
330e892ff6
Make parse_json static
2009-11-29 13:00:47 +02:00
Petri Lehtinen
d3959a8ce7
load: Parse a badly put - sign correctly
...
Thanks to Manolis Delakis for reporting.
2009-10-29 15:45:16 +02:00
Petri Lehtinen
f243930b68
json_load_file: Initialize the error struct properly
...
Failing to do this has the effect that the error message is not
returned when the input file cannot be opened (e.g. if it doesn't
exist).
Thanks to Martin Vopatek for reporting.
2009-10-27 17:56:02 +02:00
Petri Lehtinen
86dc1d629b
Fix indentation
...
No functional changes.
2009-10-16 21:20:38 +03:00
Petri Lehtinen
ca7703fbd1
Merge branch '1.0'
...
Conflicts:
configure.ac
doc/conf.py
2009-10-11 21:51:54 +03:00
Petri Lehtinen
19588c2d69
Fix a few more compilation issues
...
These were left out from the previous commit.
2009-10-06 13:22:27 +03:00
Petri Lehtinen
9c5a8430db
Make it compile on platforms where char is unsigned
...
Linux on powerpc seems to be one such platform.
2009-10-01 21:54:45 +03:00
Petri Lehtinen
6d8c287032
load: Check for integer and real overlfows and underflows
...
Backported from master, commit 5406c2b3d3
:
* deleted test/testdata/invalid-stripped because the stripped tests
don't exist in 1.0
2009-09-14 10:28:03 +03:00
Petri Lehtinen
5406c2b3d3
load: Check for integer and real overlfows and underflows
2009-09-13 13:18:01 +03:00
Petri Lehtinen
55d2566539
Merge branch '1.0' into HEAD
...
Conflicts:
configure.ac
doc/conf.py
2009-09-08 17:02:39 +03:00
Petri Lehtinen
0f62dac627
load: Handle EOF correctly
...
In stream_get(), EOF never got it to stream->buffer and because of
this, stream_unget() failed on some situations. This patch makes
stream_get() handle EOF just like any other byte.
As a "side effect", lex_scan_string() now needs to unget the EOF, or
otherwise it ends up in error message on premature end of input.
2009-09-08 16:41:07 +03:00
Petri Lehtinen
98a8c1aebf
Don't include unistd.h
...
It's not needed.
2009-09-06 22:24:22 +03:00
Petri Lehtinen
93c5892bc3
load: Factor out an unneeded strdup
...
By "stealing" the string parsed out in lexer, one strdup can be saved.
2009-09-04 09:52:40 +03:00
Petri Lehtinen
ee2d164025
Detect garbage near EOF in json_loadf() and json_load_file()
2009-08-24 20:58:59 +03:00
Petri Lehtinen
2f4d6f8ae7
Add LICENSE and a copyright note to all sources
2009-07-30 11:32:24 +03:00
Petri Lehtinen
f41e380984
Rename json_{load,dump} to json_{load,dump}_file
2009-07-28 10:58:13 +03:00
Petri Lehtinen
b348519e96
Fix some memory leaks and invalid memory references
2009-07-28 10:38:21 +03:00
Petri Lehtinen
9240146c10
Implement support for \u escapes
2009-07-16 09:58:23 +03:00
Petri Lehtinen
a0435e3061
Show the whole UTF-8 sequence in error message, not just the first byte
2009-07-16 09:57:08 +03:00
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