aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2017-04-19Enable optional object/array members in json_pack()Nathaniel McCallum1-0/+24
2017-02-27Add JSON_EMBED encoding flagNathaniel McCallum1-0/+34
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-01-27Implement json_dumpfd() and json_loadfd()Nathaniel McCallum2-4/+50
The primary use of these functions is easy loading and dumping from stream sockets. Signed-off-by: Nathaniel McCallum <npmccallum@redhat.com>
2017-01-26Implement json_dumpb()Nathaniel McCallum1-0/+26
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>
2016-09-18Update copyrights for 2016Petri Lehtinen21-21/+21
2016-09-07Added test files to .gitignoreYuriy Romanenko1-0/+4
2016-08-31Add support for the cleanup attribute in GCC/ClangNathaniel McCallum1-0/+13
The new json_auto_t macro allows easy declaration of json_t types that automatically decrement at the end of their scope.
2016-08-25Merge pull request #293 from akheron/object-insertion-orderPetri Lehtinen2-37/+29
Always preserve insertion order of object items
2016-08-11Conform to c89Andreas Pasiopoulos1-2/+3
2016-08-11Add a test case for OOM while allocating memoryAndreas Pasiopoulos1-1/+43
2016-06-20Always preserve insertion order of object itemsPetri Lehtinen2-37/+29
2016-05-03Fix for issue #282Dmitry Janushkevich2-0/+3
The fix limits recursion depths when parsing arrays and objects. The limit is configurable via the `JSON_PARSER_MAX_DEPTH` setting within `jansson_config.h` and is set by default to 2048. Update the RFC conformance document to note the limit; the RFC allows limits to be set by the implementation so nothing has actually changed w.r.t. conformance state. Reported by Gustavo Grieco.
2016-02-23Implemented json_pack() format specifiers 's?', 'o?', and 'O?'.David Harvey-Macaulay1-0/+48
2015-12-23Merge pull request #263 from wking/display-first-unrecognized-keyPetri Lehtinen2-7/+29
pack_unpack: List first unrecognized key in strict unpacking
2015-12-22pack_unpack: List unrecognized keys in strict unpackingW. Trevor King2-7/+29
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-21Add json_get_alloc_funcs() to allow alloc function fetchingNathaniel McCallum1-1/+6
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-09-08Merge pull request #248 from phoenix0428/patch-1Petri Lehtinen1-1/+1
Update test_memory_funcs.c
2015-08-26Add json_object_foreach_safePetri Lehtinen1-0/+19
Fixes #230.
2015-08-13Update test_memory_funcs.cKinam Kim1-1/+1
2015-02-05test_object: Fix a duplicate conditional check in test_iteratorsLioncash1-1/+1
2015-01-13Disable warning for deliberate use on MSVS.Joakim Soderberg1-12/+29
Disable "warning C4756: overflow in constant arithmetic" when deliberately triggering it in a test using infinity.
2014-12-19Increase test coveragePetri Lehtinen3-0/+67
2014-12-19Add a test case for \u0000Petri Lehtinen2-0/+3
2014-12-18Honor JSON_DECODE_INT_AS_REAL at lexical stagePetri Lehtinen1-0/+14
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-15wip: add testsPetri Lehtinen2-0/+3
2014-10-03Use expr instead of $((...)) in shell scriptsPetri Lehtinen1-3/+3
For Solaris 10 compatibility.
2014-10-03Don't use the nonstandard __FUNCTION__ macroPetri Lehtinen1-1/+1
2014-08-27Parse subnormal numbers correctlyPetri Lehtinen2-0/+2
Fixes #202.
2014-07-16Fix whitespace issuesIan T. Jacobsen1-4/+4
2014-07-16Fixed cases where file would be opened, but not closed. And small realloc ↵Ian T. Jacobsen1-3/+7
memory issue.
2014-05-07Add missing tests for JSON_REAL_PRECISIONPetri Lehtinen3-0/+4
2014-04-30Add JSON_REAL_PRECISIONPetri Lehtinen1-5/+24
Fixes #178.
2014-02-15Allow to mix JSON_STRICT with optional keysVincent Bernat1-0/+19
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-11Merge branch '2.6'Petri Lehtinen7-31/+66
2014-02-11CVE-2013-6401: Change hash function, randomize hashesPetri Lehtinen7-31/+66
Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing and testing.
2014-02-11expect "export" in test configsChip Salzenberg1-4/+3
2014-01-28Update copyrights for 2014Petri Lehtinen21-21/+21
2014-01-27Renamed config.h -> jansson_private_config.hJoakim Soderberg3-3/+3
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.
2013-12-04Add json_boolean_value as alias for json_is_truePetri Lehtinen1-0/+2
Fixes #146.
2013-11-14Merge branch '2.5'Petri Lehtinen1-1/+1
2013-11-14doc: Set all memory to zero in secure_freePetri Lehtinen1-1/+1
2013-10-03in simple string tests, always check lengths tooChip Salzenberg1-4/+30
2013-09-30Add JSON_ALLOW_NUL decoding flag for enabling NUL byte supportPetri Lehtinen4-2/+36
2013-09-30Fix NUL byte check for object keysPetri Lehtinen2-0/+3
2013-09-27expect "export" in test configsChip Salzenberg1-4/+3
2013-09-27dump \u sequences as upper case for readability (just like error messages)Chip Salzenberg1-1/+1
2013-09-27Support \u0000 - add size_t string lengths to API, load and dump \u000, etc.Chip Salzenberg6-9/+40
Also: Steal strings during parsing for half the mallocs! Change all input-caused assertions to errors. No crashes please, we're programmers.
2013-08-14pack: Add format specifiers s#, + and +#Petri Lehtinen1-2/+50
2013-07-23Update copyrights for 2013Petri Lehtinen20-20/+20
2013-06-13Prevent unused-variable warningJason Choy1-0/+2