Commit Graph

25 Commits

Author SHA1 Message Date
Petri Lehtinen
a8f5fa5f5a Tweak clang-format configuration a bit
Set ColumnLimit to 90, remove AllowShortCaseLabelsOnASingleLine.
2019-10-21 08:56:03 +03:00
Petri Lehtinen
79fe8c3435 Run clang-format on *.c, *.h 2019-10-21 08:55:01 +03:00
AllenX2018
78ea35c8e9 fix issue #426 2019-10-08 16:19:40 +08:00
allen
c49fbc7082 correct spelling mistake 2019-07-22 11:00:31 +08:00
Nathaniel McCallum
b8bb078cc2 Add JSON_EMBED encoding flag
The JSON_EMBED encoding flag causes the opening and closing characters
of the top-level array ('[', ']') or object ('{', '}') to be omitted
during encoding. This feature makes it possible to concatenate multiple
arrays or objects in the stream output. It also makes it possible to
perform outputs of partial composes.

One such example of a partial compose is when outputting a JWE object.
The output is a JSON object. But it has one top-level attribute
("ciphertext") that can grow out of proportion with the rest of the
metadata. With the JSON_EMBED flag, the other metadata can be composed
ahead of time and dumped during the beginning of output, where the
"ciphertext" and "tag" attributes can be streamed out in chunks. Thus,
the header material can be composed with Jansson and the ciphertext
itself can be composed manually.
2017-02-27 15:09:03 -05:00
Nathaniel McCallum
1672bb5a65 Implement json_dumpfd() and json_loadfd()
The primary use of these functions is easy loading
and dumping from stream sockets.

Signed-off-by: Nathaniel McCallum <npmccallum@redhat.com>
2017-01-27 09:15:18 +01:00
Nathaniel McCallum
b900967f6f Implement json_dumpb()
This function encodes the json_t object to a pre-allocated buffer.
It compliments the already existing json_loadb() function and is
useful for parsing JSON-RPC (among other protocols) when sent over
datagram sockets.

Signed-off-by: Nathaniel McCallum <npmccallum@redhat.com>
2017-01-26 16:16:24 +01:00
Petri Lehtinen
074bb3838f Update copyrights for 2016 2016-09-18 14:17:03 +03:00
Petri Lehtinen
890760b2fb Increase test coverage 2014-12-19 08:35:46 +02:00
Petri Lehtinen
30fdf6067e Update copyrights for 2014 2014-01-28 09:16:05 +02: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
2489ea90b1 Update copyrights for 2013 2013-07-23 13:20:06 +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
42e307b3c5 Fix the signature of a test function 2013-04-15 09:08:47 +03:00
Petri Lehtinen
867079c820 json_dump*(): Don't crash if json is NULL and JSON_ENCODE_ANY is set 2013-04-15 08:49:09 +03:00
Juan Basso
b217cd6689 Created flag to dump escaping slash 2012-06-28 22:04:36 -04:00
Petri Lehtinen
3c6e36ba2d Update copyright notices for 2012 2012-03-20 20:55:55 +02:00
Petri Lehtinen
d7ddbf3661 Make real number encoding and decoding work under all locales
The decimal point '.' is changed to locale's decimal point
before/after JSON conversion to make C standard library's
locale-specific string conversion functions work correctly.

All the tests now call setlocale(LC_ALL, "") on startup to use the
locale set in the environment.

Fixes GH-32.
2011-10-02 21:31:17 +03:00
Petri Lehtinen
636d5f60f9 Add JSON_ENCODE_ANY flag to allow encoding any JSON value
Closes GH-19.
2011-05-14 12:57:12 +03:00
Petri Lehtinen
fa7c2ea070 Update copyright notices for 2011 2011-01-22 13:43:14 +02:00
Petri Lehtinen
1a090bbcd3 Fix a few memory leaks in tests
No changes to the actual library code.
2010-06-10 21:16:07 +03:00
Petri Lehtinen
453e4c0aa2 Zero the visited flag after an encoding error
When encoding an array or object ends in an error, the visited flag
wasn't zeroed, causing subsequent encoding attempts to fail. This
patch fixes the problem by always zeroing the visited flag.
2010-05-14 09:23:35 +03:00
Petri Lehtinen
2630980f49 Zero the visited flag after encoding an empty array or object
Encoding an empty array or object worked, but encoding it again
(possibly after adding some items) failed, because the visited flag
(used for detecting circular references) wasn't zeroed.
2010-05-14 09:05:56 +03:00
Petri Lehtinen
3889af476b Enhance tests
* Now that JSON_SORT_KEYS is implemented, take it into use with the
  valid and valid-strip suites. This is to ensure that the tests
  remain valid even if the string hash function is changed in the
  future.

* Remove test_dump API test. Instead, implement the same tests more
  elegantly in the encoding-flags suite.
2009-12-21 12:50:49 +02:00
Petri Lehtinen
3add1cf361 Refactor the test system 2009-12-16 22:45:29 +02:00