Maxim Zhukov
0758caaac0
reuse key len from loop check for better performance
...
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-09-01 10:22:14 +03:00
Maxim Zhukov
ba4503804b
pass length of the key to internal API
...
Use key length for internal API
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-08-12 09:57:14 +03:00
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
allen
53e9dd848f
add the loop key length macro for circular reference detect
2019-09-16 15:50:59 +08:00
allen
63fb81faa5
add loop check in json deep copy #457
2019-08-12 11:17:25 +08:00
Corey Farrell
6ac0eefed0
Merge pull request #436 from edgale/warnings
...
removed various warnings
2018-10-17 06:29:47 -04:00
Maximilian Röhrle
226b34d546
fixed extra bracket
2018-10-15 07:05:02 +02:00
Maximilian Röhrle
d115953347
removed explicit casts
2018-10-15 06:58:19 +02:00
Maximilian Röhrle
fc591913ac
removed various warnings
2018-08-31 09:01:36 +02:00
Maximilian Röhrle
d83d3d9172
This fixes https://github.com/akheron/jansson/issues/434
2018-08-30 14:45:28 +02:00
Petri Lehtinen
020cc26b5c
Rename a varialble that shadows another one
...
Fixes #430
2018-08-12 18:25:51 +03:00
Corey Farrell
37e0ee4d48
json_dump: Fix thread safety issue.
...
Circular reference detection in json_dump was not thread safe. Replace
visited flag with a hashtable_t.
Issue #387
2018-02-01 15:54:25 -05:00
Sanjay Kumar
0abcbce3bb
json_dump_file API returns success even when fclose fails (consider disk full case). API should check the return value of fclose before returning success to its caller. fwrite may not write anything into the file, it simply returns the number of bytes written into the buffer. When disk is full and fclose is called, it results in truncation of the file (resulting in zero sized file). Since, API is returning success, its caller can't take any remedial action on its failure.
2017-08-05 23:52:49 +05:30
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
9df267054f
Always preserve insertion order of object items
2016-06-20 21:10:23 +03:00
Jonas Jonsson
e89538f685
Format %x expects unsigned int, not int
...
Be more explicit that a cast is happening.
2015-10-05 14:00:44 +02:00
Jonas Jonsson
f7331c7194
Use sizeof(seq) instead of magic number 13
...
Be more future proof by keeping the number of magic constants low.
2015-10-05 13:59:09 +02:00
Folkert van Heusden
5d42e1520a
Optimized dump_indent to reduce the number of fwrite calls.
2015-05-01 15:18:53 +02:00
Haldean
95dd927857
use snprintf and strncpy in place of sprintf and strcpy
...
This is both good practice and nice for OpenBSD users, who will no
longer get the nag message to not use sprintf/strcpy every time they
link against jansson. It's worth noting that the existing code seems
safe to me - bounds checks were already happening before the actual
calls - and that this is for extra security.
2015-04-30 00:11:25 -07:00
Shawn Harris
9b435df3d4
Warnings - use size_t where appropriate to prevent warning when compilation is targeting 64 bit
2014-11-28 18:11:26 -07:00
Petri Lehtinen
17b5fdd94b
Add JSON_REAL_PRECISION
...
Fixes #178 .
2014-04-30 12:46:34 +03:00
Petri Lehtinen
30fdf6067e
Update copyrights for 2014
2014-01-28 09:16:05 +02: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
2489ea90b1
Update copyrights for 2013
2013-07-23 13:20:06 +03:00
Petri Lehtinen
61cba2ae50
Merge branch '2.4'
2013-04-15 08:49: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
Petri Lehtinen
6281d1c549
Merge pull request #108 from Zillode/1edff47af38a2335f88300ee6dc437118f5a20ff
...
Fixes redefined warnings ("_GNU_SOURCE")
2013-04-02 05:40:49 -07:00
Lode Hoste
1edff47af3
Do not define _GNU_SOURCE is already defined
2013-03-14 21:34:11 +01:00
Jacob Potter
f86bb0377f
Mark some constant data as const.
...
Issue #95 .
2012-12-10 08:47:00 +02:00
Petri Lehtinen
37bc3bbf4b
Tweak slash escaping
2012-06-29 13:25:02 +03:00
Petri Lehtinen
2d46ea069b
Merge branch 'fix-slash' of git://github.com/jrbasso/jansson
...
Fixes #81 .
2012-06-29 13:24:55 +03:00
Juan Basso
b217cd6689
Created flag to dump escaping slash
2012-06-28 22:04:36 -04:00
Juan Basso
a0c262d08b
Escaping the slash when dump
2012-06-27 23:54:08 -04:00
Petri Lehtinen
ff0c05b8f1
Support building on Windows
...
Jansson now builds correctly with Visual C++ Express 2010.
2012-04-29 22:09:29 +03:00
Petri Lehtinen
3c6e36ba2d
Update copyright notices for 2012
2012-03-20 20:55:55 +02:00
Petri Lehtinen
a2381948bb
Make hashtable less generic
...
This will make it possible to implement json_object_foreach(). It
should also have some (positive) effect on speed.
2012-01-24 21:01:23 +02:00
Petri Lehtinen
c4a7bf90cf
Revert "json_dump_file: Open the output file in wb mode"
...
JSON is read as text, so line endings should be preserved.
This reverts commit 32cd821273
.
2011-11-14 21:16:36 +02:00
Petri Lehtinen
0f2cdd70ff
Avoid problems with object's serial number growing too big
...
Transform serial key comparison from substraction to real comparison.
Reset serial to zero in json_object_clear() to avoid it growing out of
bounds when reusing objects.
Closes GH-40.
Closes GH-41.
2011-11-14 21:01:13 +02:00
Petri Lehtinen
32cd821273
json_dump_file: Open the output file in wb mode
...
For maximum compatibility.
2011-10-07 20:52:54 +03: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
b6d0191e51
Implement all other encoding functions using json_dump_callback
...
This way we can check for JSON_ENCODE_ANY flag in one place only.
2011-09-24 21:10:34 +03:00
JKL
c7d543d36c
new typedef json_dump_callback_t, function json_dump_callback
2011-06-30 21:47:12 +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
4be9e9e7fe
Add custom memory allocation
...
Thanks to Basile Starynkevitch for the suggestion and initial patch.
Thanks to Jonathan Landis and Deron Meranda for showing how this can
be utilized for implementing secure memory operations.
2011-02-17 10:10:53 +02:00
Petri Lehtinen
fa7c2ea070
Update copyright notices for 2011
2011-01-22 13:43:14 +02:00