Commit Graph

58 Commits

Author SHA1 Message Date
Krzysztof Gabis
a34e725282 1.4.0: Accepting trailing commas in objects and arrays
Issue #178
2022-03-06 21:27:20 +01:00
Krzysztof Gabis
4bd5797811 Fixes repository URL
#176
2022-02-18 21:28:25 +01:00
Krzysztof Gabis
6e30db3599 Updates license (version and year). 2022-01-26 12:14:25 +01:00
Krzysztof Gabis
af848c27b4 1.3.0: Adds json_set_float_serialization_format function. 2021-12-11 18:11:18 +01:00
Krzysztof Gabis
fd77bcddc1 1.2.1: Not using SIZE_MAX macro (issue #167) 2021-08-06 15:46:45 +02:00
Krzysztof Gabis
6b3d6f42f2 1.2.0: JSON objects are now implemented using hash maps, PARSON_VERSION defines (issue #37) 2021-08-05 20:24:57 +02:00
Disconnect3d
ab7f5e5401
Fix memleak when parsing keys with embedded null bytes (#157)
* Fix memleak when parsing key with embedded null byte

This commit fixes and adds a test for a memory leak that occurs when
parsing strings with keys that have a null byte embedded in them.

This memory leak can be triggered with the following line, where this
call returns a `NULL`:
```c
        json_parse_string("{\"\\u0000\"")
```

This memory leak happens in the `parse_object_value` function in here:
```
        new_key = get_quoted_string(string, &key_len);  <---- ALLOCATION
        /* We do not support key names with embedded \0 chars */
        if (new_key == NULL || key_len != strlen(new_key)) {
            json_value_free(output_value);
            return NULL;                       <---- `new_key` NOT FREED
        }
        SKIP_WHITESPACES(string);
        if (**string != ':') {
            parson_free(new_key);
            json_value_free(output_value);
            return NULL;
        }
```

* Increments version to 1.1.2

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2021-05-03 18:47:03 +02:00
benswick
60b2c69f17
Improved serialization performance (#156)
* Update parson.c

Get objects by index instead of key in json_serialize_to_buffer_r().

* Increments version and updates licence date.

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2021-04-07 22:23:01 +02:00
reuben olinsky
102a4467e1
Add support for string values with embedded '\0' characters (#137)
* Add support for strings with \0 chars

* address feedback

* Increments minor version, adds comments, changes license year

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2020-04-16 21:55:56 +02:00
Krzysztof Gabis
70dc239f8f Optional tests directory path argument in tests.c 2020-02-20 20:39:41 +01:00
Krzysztof Gabis
2be6991d84 Adds tests to avoid json_object_set_* memory leaks (fixed in 39c2d51). 2019-11-12 09:01:03 +01:00
Krzysztof Gabis
c5bb9557fe Updates copyright year. 2019-07-11 18:33:44 +02:00
Akihiro Suda
9ec77a8d74 add SPDX-License-Identifier
SPDX-License-Identifier is useful to clarify the license (both for humans and
machines), especially when the code of the project is embedded into other
projects.

ref: https://spdx.org/using-spdx-license-identifier

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2019-07-11 21:23:37 +09:00
Krzysztof Gabis
302fba9cbb Makes escaping slashes when serializing JSON optional (adds json_set_escape_slashes() function)
Issues #20 #34 #90
2018-11-26 20:12:16 +01:00
zolvarga
69684f600c Remove trailing spaces 2018-09-06 13:30:52 -07:00
Krzysztof Gabis
387c5665f6 Better handling of CRLF line breaks. 2018-02-06 20:32:02 +01:00
Krzysztof Gabis
c147744b72 Workaround for MSVC C2124 error. 2018-01-04 18:41:43 +01:00
tbeu
1839d0de54 Fix typos 2017-10-02 08:47:53 +02:00
Krzysztof Gabis
4e8a901242 Changes float print format, removes array/object capacity limit, doesn't accept inf/nan numbers. 2017-09-16 16:07:43 +01:00
Krzysztof Gabis
e18751499d Adds a simple memory leak test. 2017-09-14 21:01:32 +01:00
Krzysztof Gabis
e1292a0e3c Small refactoring in parse_utf16 (+ tests) and typo fix in json_array_remove. 2017-09-14 10:00:24 +01:00
Krzysztof Gabis
578b25e590 Counting malloc and free calls to avoid memory leaks (#82). 2017-09-06 10:13:23 +01:00
Krzysztof Gabis
343fe13f17 Order of items in an array is preserved after removing an item.
Issue #81
2017-09-06 10:02:52 +01:00
Krzysztof Gabis
e410fc7c33 Increases MAX_NESTING of json objects/arrays to 2048.
Fixes #75
2017-05-08 19:55:29 +01:00
Krzysztof Gabis
2bfa4153db Updates copyright. 2017-02-18 16:41:14 +00:00
Krzysztof Gabis
96150ba1fd Removes dependency on sscanf and prints line numbers in tests output.
Some libraries don't have sscanf and since it wasn't used heavily it was easily replaced with a custom function. This doesn't mean that sscanf won't be used in future though (but I'll try to avoid it).
Fixes #68. Thanks to @compulim for initial work on this issue.
2017-02-18 15:26:22 +00:00
Krzysztof Gabis
cb14736e96 Checking errno after strtod call. 2017-01-06 21:35:29 +01:00
Krzysztof Gabis
f419334a32 Adds links to parent values and values used to wrap objects/arrays. Assigning a value to 2 objects/arrays returns an error now.
Addresses issues #66 and #30.
2016-12-29 23:50:20 +01:00
Krzysztof Gabis
a1c356eaa9 Adds functions to check if object has value with a certain name (and optionally type).
This closes #42.
2016-07-05 12:23:17 +02:00
Jacob Enget
9d6fbde0c4 Adds test that fails when validating array elements 2016-06-06 13:44:44 -05:00
Krzysztof Gabis
5c4a11b036 Removes trailing whitespace. 2016-04-23 12:11:25 +02:00
Krzysztof Gabis
f860d3dd1b Accepting json texts that are not objects or arrays.
According to RFC 7159 it's now valid to accept json texts that are not object or arrays.
Also reordered realloc opeartion in json_object_add to not be called if key already exists.
2016-04-16 12:30:46 +01:00
Krzysztof Gabis
c9b920c4a3 Fixes a bug in json_array_remove and adds relevant tests (thanks to KB for finding this).
Also - it's 2016, time to update copyright notices, yay!
2016-01-13 20:47:47 +00:00
Krzysztof Gabis
f16e4292f3 Using same code for determining serialization buffer size and serialization. Updated license year. 2015-06-26 00:12:06 +02:00
Krzysztof Gabis
f4cfcd7699 Updates serialization example and readme.md 2015-06-22 19:30:06 +02:00
Krzysztof Gabis
6905548257 Pretty serialization + tests. 2015-06-22 16:53:19 +02:00
Krzysztof Gabis
7fd8dc1c4c UTF8 validation in json_value_init_string (+ tests). 2015-05-03 12:55:48 +01:00
Krzysztof Gabis
4a4cf7d795 Not parsing strings in json_value_init_string and *{set,dotset,replace,append}_string functions. 2015-04-06 10:12:04 +02:00
Krzysztof Gabis
0d5ac45286 Added additional null checks and tests. 2015-04-05 15:26:58 +02:00
Krzysztof Gabis
1058e3b2c0 Fixed bug in example code. 2014-11-24 21:04:15 +01:00
Krzysztof Gabis
c88c775d23 Fixed floating point number comparison in tests (using fabs). 2014-11-23 12:39:47 +01:00
Krzysztof Gabis
e4ac46318e Fixed memory leak in example. 2014-10-08 14:45:39 +02:00
Krzysztof Gabis
638190d6a0 Merged changes from parson-devel (serialization, copying, comparing, validation, creating values). 2014-10-07 21:11:29 +02:00
Krzysztof Gabis
6e9e934b5a Bugfix in parsing escaped characters (+ additional tests to prevent this bug in future).
Thanks to Joseph Werle for bringing attention to it.
2014-06-10 20:59:35 +02:00
Krzysztof Gabis
c707051778 Added surrogate pairs support (JSON support is full now), removed PARSON_VERSION macro. 2014-04-10 17:00:40 +02:00
Krzysztof Gabis
d5adf4e291 Added functions to parse file with comments and new tests.
json_parse_value_with_comments and json_parse_string_with_comments replace comments with whitespaces before parsing. Supported comments are: /* */ and //
2013-11-30 20:22:16 +01:00
Taro Kobayashi
155f7f0639 added test that will fails on android 2013-02-07 17:23:57 +09:00
Krzysztof Gabis
c24b1a1ad0 Fixed type mismatch in array indexing variables, updated readme file.
Also removed trailing whitespace.
2012-12-02 18:33:00 +01:00
Krzysztof Gabis
457fa1100f Small code cleanup, narrower example code in tests and readme. 2012-11-24 20:59:16 +01:00
Krzysztof Gabis
aaf1d45f16 Code refractoring.
Details:
- Increased STARTING_CAPACITY from 10 to 15.
- Added 2 macros: skip_char and skip_whitespaces.
- Added json_object_nget_value function, which removes neccessity to allocate new string when using dotget functions.
- Removed parson_strdup function, it was called only once and could be easilly replaced with appropriate call to parson_strndup.
- Renamed skip_string to skip_quotes, which is a more appropriate name, and made it work on a passed pointer to a string, which is much like skip_char and skip_whitespaces.
- Removed copy_and_remove_whitespaces, it was unncessary, and could be easily replaced with skip_whitepsaces macro.
- Merged parse_escaped_characters and get_string to get_processed_string, which makes more sense.
- Changed is_decimal implementation, to avoid unncessary string duplicating.
- Removed string copying in parse_number value and json_parse_string, since it was unncessary.
2012-11-04 17:45:52 +01:00