Skip to content

Commit 3ebe0d8

Browse files
committed
Merge branch 'develop'
2 parents 87a6128 + 783f43c commit 3ebe0d8

File tree

242 files changed

+10914
-8264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+10914
-8264
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ All notable changes to this project will be documented in this file.
55

66
## Unreleased
77
#### Added
8-
- Add `yyjson_write_number()` and `yyjson_mut_write_number()` functions to write a number value to a string buffer.
8+
- Add `yyjson_write_number()` and `yyjson_mut_write_number()` to write a number value to a string buffer.
9+
- Add `YYJSON_READ_ALLOW_EXT_NUMBER` to support extended number formats, such as `0x7B`, `+.123`.
10+
- Add `YYJSON_READ_ALLOW_EXT_ESCAPE` to support extended escape, such as `\a`, `\0`, `\x7B`.
11+
- Add `YYJSON_READ_ALLOW_EXT_WHITESPACE` to support extended whitespace, such as `\v`, `\u2028`.
12+
- Add `YYJSON_READ_ALLOW_SINGLE_QUOTED_STR` to support single-quoted strings, such as `'ab'`.
13+
- Add `YYJSON_READ_ALLOW_UNQUOTED_KEY` to allow unquoted keys, such as `{a:1,b:2}`.
14+
- Add `YYJSON_READ_JSON5` to enable full JSON5 support: [json5.org](https://json5.org).
15+
16+
#### Changed
17+
- Removed support for non-standard JSON in the incremental reader `yyjson_incr_read()`.
918

1019

1120
## 0.11.1 (2025-05-14)

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,7 @@ if(YYJSON_BUILD_MISC)
524524
endif()
525525

526526
# make tables
527-
find_package(GMP REQUIRED)
528-
find_package(MPFR REQUIRED)
529527
add_executable(make_tables "misc/make_tables.c")
530-
target_include_directories(make_tables PRIVATE
531-
${GMP_INCLUDE_DIR}
532-
${MPFR_INCLUDES}
533-
)
534-
target_link_libraries(make_tables PRIVATE
535-
${GMP_LIBRARIES}
536-
${MPFR_LIBRARIES}
537-
)
538528
if(XCODE)
539529
set_default_xcode_property(make_tables)
540530
endif()

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
A high performance JSON library written in ANSI C.
1111

1212
# Features
13-
- **Fast**: can read or write gigabytes per second JSON data on modern CPUs.
13+
- **Fast**: can read or write gigabytes of JSON data per second on modern CPUs.
1414
- **Portable**: complies with ANSI C (C89) for cross-platform compatibility.
15-
- **Strict**: complies with [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259) JSON standard, ensuring strict number format and UTF-8 validation.
16-
- **Extendable**: offers options to allow comments, trailing commas, NaN/Inf, and custom memory allocator.
15+
- **Strict**: complies with [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259) JSON standard, ensuring strict number formats and UTF-8 validation.
16+
- **Extendable**: offers options to enable individual JSON5 features and custom allocator.
1717
- **Accuracy**: can accurately read and write `int64`, `uint64`, and `double` numbers.
18-
- **Flexible**: supports unlimited JSON nesting levels, `\u0000` characters, and non null-terminated strings.
19-
- **Manipulation**: supports querying and modifying using [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901), [JSON Patch](https://datatracker.ietf.org/doc/html/rfc6902) and [JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7386).
20-
- **Developer-Friendly**: easy integration with only one `h` and one `c` file.
18+
- **Flexible**: supports unlimited JSON nesting levels, `\u0000` characters, and non-null-terminated strings.
19+
- **Manipulation**: supports querying and modifying with [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901), [JSON Patch](https://datatracker.ietf.org/doc/html/rfc6902), and [JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7386).
20+
- **Developer-Friendly**: easy integration with just one `.h` and one `.c` file.
2121

2222
# Limitations
2323
- An array or object is stored as a [data structure](https://ibireme.github.io/yyjson/doc/doxygen/html/md_doc__data_structure.html) such as linked list, which makes accessing elements by index or key slower than using an iterator.
@@ -205,7 +205,7 @@ The pre-generated Doxygen HTML for the release version can be viewed here:
205205

206206
# Packaging status
207207

208-
[![Packaging status](https://repology.org/badge/vertical-allrepos/yyjson.svg)](https://repology.org/project/yyjson/versions)
208+
[![Packaging status](https://repology.org/badge/vertical-allrepos/yyjson.svg?columns=2)](https://repology.org/project/yyjson/versions)
209209

210210
# Built With yyjson
211211

@@ -235,7 +235,7 @@ yyjson, feel free to open a PR to add it to this list.
235235
* [x] Support JSON Pointer to query and modify JSON.
236236
* [x] Add `RAW` type for JSON reader and writer.
237237
* [x] Add option to limit real number output precision.
238-
* [ ] Add option to support JSON5 (if feasible).
238+
* [x] Add option to support JSON5.
239239
* [ ] Add functions to diff two JSON documents.
240240
* [ ] Add documentation on performance optimizations.
241241
* [ ] Ensure ABI stability.

cmake/FindGMP.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmake/FindMPFR.cmake

Lines changed: 0 additions & 83 deletions
This file was deleted.

doc/API.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ Incremental reading is recommended only for large documents and only when the
184184
program needs to be responsive. Incremental reading is slightly slower than
185185
`yyjson_read()` and `yyjson_read_opts()`.
186186

187+
Note: The incremental JSON reader only supports standard JSON.
188+
Flags for non-standard features (e.g. comments, trailing commas) are ignored.
189+
187190
To read a large JSON document incrementally:
188191

189192
1. Call `yyjson_incr_new()` to create the state for incremental reading.
@@ -378,12 +381,12 @@ Allow a single trailing comma at the end of an object or array (non-standard), f
378381
```
379382

380383
### **YYJSON_READ_ALLOW_COMMENTS**
381-
Allow C-style single line and multiple line comments (non-standard), for example:
384+
Allow C-style single-line and multi-line comments (non-standard), for example:
382385

383386
```
384387
{
385-
"name": "Harry", // single line comment
386-
"id": /* multiple line comment */ 123
388+
"name": "Harry", // single-line comment
389+
"id": /* multi-line comment */ 123
387390
}
388391
```
389392

@@ -433,6 +436,45 @@ This flag permits invalid characters to appear in the string values, but it stil
433436
### **YYJSON_READ_ALLOW_BOM**
434437
Allow UTF-8 BOM and skip it before parsing if any (non-standard).
435438
439+
### **YYJSON_READ_ALLOW_EXT_NUMBER**
440+
Allow extended number formats (non-standard):
441+
- Hexadecimal numbers, such as `0x7B`.
442+
- Numbers with leading or trailing decimal point, such as `.123`, `123.`.
443+
- Numbers with a leading plus sign, such as `+123`.
444+
445+
### **YYJSON_READ_ALLOW_EXT_ESCAPE**
446+
Allow extended escape sequences in strings (non-standard):
447+
- Additional escapes: `\a`, `\e`, `\v`, ``\'``, `\?`, `\0`.
448+
- Hex escapes: `\xNN`, such as `\x7B`.
449+
- Line continuation: backslash followed by line terminator sequences.
450+
- Unknown escape: if backslash is followed by an unsupported character,
451+
the backslash will be removed and the character will be kept as-is.
452+
However, `\1`-`\9` will still trigger an error.
453+
454+
### **YYJSON_READ_ALLOW_EXT_WHITESPACE**
455+
Allow extended whitespace characters (non-standard):
456+
- Vertical tab `\v` and form feed `\f`.
457+
- Line separator `\u2028` and paragraph separator `\u2029`.
458+
- Non-breaking space `\xA0`.
459+
- Byte order mark: `\uFEFF`.
460+
- Other Unicode characters in the Zs (Separator, space) category.
461+
462+
### **YYJSON_READ_ALLOW_SINGLE_QUOTED_STR**
463+
Allow strings enclosed in single quotes (non-standard), such as ``'ab'``.
464+
465+
### **YYJSON_READ_ALLOW_UNQUOTED_KEY**
466+
Allow object keys without quotes (non-standard), such as `{a:1,b:2}`.
467+
This extends the ECMAScript IdentifierName rule by allowing any
468+
non-whitespace character with code point above `U+007F`.
469+
470+
### **YYJSON_READ_JSON5**
471+
Allow JSON5 format, see: https://json5.org.
472+
473+
This flag supports all JSON5 features with some additional extensions:
474+
- Accepts more escape sequences than JSON5 (e.g. `\a`, `\e`).
475+
- Unquoted keys are and not limited to ECMAScript IdentifierName.
476+
- Allow case-insensitive `NaN`, `Inf` and `Infinity` literals.
477+
436478
437479
---------------
438480
# Writing JSON

fuzz/fuzzer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
1717
YYJSON_READ_NOFLAG,
1818
YYJSON_WRITE_NOFLAG);
1919
test_with_flags(data, size,
20-
YYJSON_READ_ALLOW_TRAILING_COMMAS |
21-
YYJSON_READ_ALLOW_COMMENTS |
22-
YYJSON_READ_ALLOW_INF_AND_NAN,
20+
YYJSON_READ_JSON5,
2321
YYJSON_WRITE_PRETTY |
2422
YYJSON_WRITE_ESCAPE_UNICODE |
2523
YYJSON_WRITE_ESCAPE_SLASHES |

0 commit comments

Comments
 (0)