Commit Graph

203 Commits

Author SHA1 Message Date
David Harvey-Macaulay
107cfe9499 Implemented json_pack() format specifiers 's?', 'o?', and 'O?'. 2016-02-23 19:28:56 +00:00
Petri Lehtinen
52015cf35c Merge pull request #263 from wking/display-first-unrecognized-key
pack_unpack: List first unrecognized key in strict unpacking
2015-12-23 07:38:03 +02:00
W. Trevor King
1d513d063a pack_unpack: List unrecognized keys in strict unpacking
Otherwise figuring out what's wrong with your JSON can be tricky,
especially if you're using a single fmt string to validate a large,
complicated schema.

The comma delimiting will make separating keys that contain commas
difficult.  For example:

  {"foo, bar": true, "baz": false}

will generate errors like:

  2 object item(s) left unpacked: foo, bar, baz

but that seems like a small enough corner case to not be worth much
worrying.

I wanted to find a way to handle this without have_unrecognized_keys,
but the strbuffer tooling makes it look like I shouldn't be reaching
in to do things like:

  strbuffer_t unrecognized_keys;
  unrecognized_keys.value = NULL;

and then using 'unrecognized_keys.value == NULL' in place of
have_unrecognized_keys.
2015-12-22 10:05:31 -08:00
Nathaniel McCallum
245e532934 Add json_get_alloc_funcs() to allow alloc function fetching
This is particularly useful in modular situations where the allocation
functions are either unknown or private. For instance, in such cases,
the caller of json_dumps() has no way to free the returned buffer.
2015-12-21 11:46:32 -05:00
Petri Lehtinen
02464862ed Merge pull request #248 from phoenix0428/patch-1
Update test_memory_funcs.c
2015-09-08 21:13:08 +03:00
Petri Lehtinen
4c4f692bd6 Add json_object_foreach_safe
Fixes #230.
2015-08-26 17:32:55 +03:00
Kinam Kim
875b78dc97 Update test_memory_funcs.c 2015-08-13 16:44:31 +09:00
Lioncash
c242b46016 test_object: Fix a duplicate conditional check in test_iterators 2015-02-05 01:26:13 -05:00
Joakim Soderberg
6a38d0d431 Disable warning for deliberate use on MSVS.
Disable "warning C4756: overflow in constant arithmetic" when deliberately
triggering it in a test using infinity.
2015-01-13 16:30:00 +01:00
Petri Lehtinen
890760b2fb Increase test coverage 2014-12-19 08:35:46 +02:00
Petri Lehtinen
15653c47dd Add a test case for \u0000 2014-12-19 07:57:33 +02:00
Petri Lehtinen
5508ab403d Honor JSON_DECODE_INT_AS_REAL at lexical stage
This has the consequence that numbers are never converted to integers
when JSON_DECODE_INT_AS_REAL is set, and thus it works correctly all
integers that are representable as double.

Fixes #212.
2014-12-18 15:16:14 +02:00
Petri Lehtinen
5c1d87592a wip: add tests 2014-12-15 08:30:59 +02:00
Petri Lehtinen
d7a6269a17 Use expr instead of $((...)) in shell scripts
For Solaris 10 compatibility.
2014-10-03 08:49:08 +03:00
Petri Lehtinen
7fbe7c3960 Don't use the nonstandard __FUNCTION__ macro 2014-10-03 08:38:57 +03:00
Petri Lehtinen
fa20e80860 Parse subnormal numbers correctly
Fixes #202.
2014-08-27 07:59:52 +03:00
Ian T. Jacobsen
4f1238af71 Fix whitespace issues 2014-07-16 00:21:16 +01:00
Ian T. Jacobsen
122a1e2af9 Fixed cases where file would be opened, but not closed. And small realloc memory issue. 2014-07-16 00:16:32 +01:00
Petri Lehtinen
4debe8e567 Add missing tests for JSON_REAL_PRECISION 2014-05-07 08:19:39 +03:00
Petri Lehtinen
17b5fdd94b Add JSON_REAL_PRECISION
Fixes #178.
2014-04-30 12:46:34 +03:00
Vincent Bernat
7a0b9af662 Allow to mix JSON_STRICT with optional keys
On unpack, one may want to mix `JSON_STRICT` and optional keys by using
a format like `{s:i,s?o!}`. Unfortunately, this fails the stric test
with `-1 object item(s) left unpacked` error when the second key is not
specified.

To fix that, we iter on each key and we check if we have successfully
unpacked them. This is less efficient than the previous method but it
brings correctness.
2014-02-15 17:40:22 +01:00
Petri Lehtinen
17ec22f514 Merge branch '2.6' 2014-02-11 14:49:15 +02:00
Petri Lehtinen
8f80c2d838 CVE-2013-6401: Change hash function, randomize hashes
Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing
and testing.
2014-02-11 08:41:30 +02:00
Chip Salzenberg
b9c588de3d expect "export" in test configs 2014-02-11 08:41:14 +02:00
Petri Lehtinen
30fdf6067e Update copyrights for 2014 2014-01-28 09:16:05 +02:00
Joakim Soderberg
3fe8f74e7f Renamed config.h -> jansson_private_config.h
This is because it's really easy to get a name collission if compiling
Jansson as a subproject in a larger CMake project. If one project includes
several subprojects each having their own config.h, this will cause the
wrong file to be loaded.
2014-01-27 12:48:52 +01:00
Petri Lehtinen
05f7d30e5a Add json_boolean_value as alias for json_is_true
Fixes #146.
2013-12-04 09:14:19 +02:00
Petri Lehtinen
34d8b92dce Merge branch '2.5' 2013-11-14 08:49:24 +02:00
Petri Lehtinen
67a7bc7376 doc: Set all memory to zero in secure_free 2013-11-14 08:49:16 +02:00
Chip Salzenberg
c7d479c740 in simple string tests, always check lengths too 2013-10-03 19:07:50 -07:00
Petri Lehtinen
1bfc33362e Add JSON_ALLOW_NUL decoding flag for enabling NUL byte support 2013-09-30 10:45:02 +03:00
Petri Lehtinen
4d5aead31c Fix NUL byte check for object keys 2013-09-30 10:45:02 +03:00
Chip Salzenberg
face43929d expect "export" in test configs 2013-09-27 17:32:25 -07:00
Chip Salzenberg
dcaa90d21e dump \u sequences as upper case for readability (just like error messages) 2013-09-27 17:32:25 -07:00
Chip Salzenberg
9c259c07aa Support \u0000 - add size_t string lengths to API, load and dump \u000, etc.
Also:
  Steal strings during parsing for half the mallocs!
  Change all input-caused assertions to errors.  No crashes please, we're programmers.
2013-09-27 17:32:06 -07:00
Petri Lehtinen
3196ad48ed pack: Add format specifiers s#, + and +# 2013-08-14 21:54:11 +03:00
Petri Lehtinen
2489ea90b1 Update copyrights for 2013 2013-07-23 13:20:06 +03:00
Jason Choy
62531bd012 Prevent unused-variable warning 2013-06-13 11:37:07 +01:00
Petri Lehtinen
f639fbd2c3 Tweak the JSON_DECODE_INT_AS_REAL test introduced in #123
Only run the imprecision part if json_int_t is long long, otherwise
the imprecision cannot be tested against json_int_t.

Also, convert the double value to json_int_t before checking the
imprecision, because otherwise the json_int_t is converted to double
and the imprecision happens in the "wrong direction".
2013-06-12 08:36:53 +03:00
Jason Choy
120a90a155 Using jsonp_strtod instead of casting to double to catch double overflow 2013-06-11 15:09:08 +01:00
Jason Choy
02a3829363 Renamed flag to JSON_DECODE_INT_AS_REAL and added documentation 2013-06-11 12:24:28 +01:00
Jason Choy
e6bd0aba9d Added a simple test for the JSON_DECODE_NO_INT option 2013-06-09 15:34:30 +01:00
Jason Choy
ddd10b5e0b Added missing rv check - caught by clang 2013-06-07 13:08:22 +01:00
Daniel Griscom
b49280be72 Fixed "comparison between signed and unsigned" warning 2013-05-12 15:45:33 -04:00
Daniel Griscom
7121134abd Removed (non-functioning) printfs from test code 2013-05-12 15:36:09 -04:00
Daniel Griscom
e8c812b500 Added test cases and documentation for json_array_foreach() 2013-05-12 15:34:26 -04:00
Andrei Epure
5793142861 test:suites:api: modified error message
In the "/* perform the same update again */" area the error
message should be "unable to update an non-empty object"
instead of "unable to update an empty object".

Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
2013-04-29 15:32:52 +03:00
Petri Lehtinen
70232676f7 Merge branch '2.4' 2013-04-15 09:15:35 +03:00
Petri Lehtinen
257a716073 Fix the signature again, and also rest of the errors
Next time, remember to check with -Werror first...
2013-04-15 09:15:03 +03:00
Petri Lehtinen
0ccd2c7715 Merge branch '2.4' 2013-04-15 09:09:01 +03:00