Skip to content

Commit a2824b8

Browse files
committed
Update doc
1 parent 1c298ec commit a2824b8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

doc/API.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,18 @@ This flag supports all JSON5 features with some additional extensions:
477477
- Unquoted keys are and not limited to ECMAScript IdentifierName.
478478
- Allow case-insensitive `NaN`, `Inf` and `Infinity` literals.
479479
480+
For example:
481+
```json
482+
{
483+
/* JSON5 example */
484+
id: 123,
485+
name: 'Harry',
486+
color: 0x66CCFF,
487+
min: .001,
488+
max: Inf,
489+
data: '\x00\xAA\xFF',
490+
}
491+
```
480492

481493
---------------
482494
# Writing JSON
@@ -1549,16 +1561,18 @@ char *yyjson_write_number(const yyjson_val *val, char *buf);
15491561
# Text Processing
15501562
15511563
## Character Encoding
1552-
This library only supports UTF-8 encoding without BOM, as specified in [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259#section-8.1):
1564+
By default, this library supports UTF-8 encoding without a BOM, as specified in [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259#section-8.1):
15531565
15541566
> JSON text exchanged between systems that are not part of a closed ecosystem MUST be encoded using UTF-8.
15551567
> Implementations MUST NOT add a byte order mark (U+FEFF) to the beginning of a networked-transmitted JSON text.
15561568
1557-
By default, yyjson performs strict UTF-8 encoding validation on input strings. If an invalid character is encountered, an error will be reported.
1569+
This library performs strict UTF-8 encoding validation on input strings by default. If an invalid character is encountered, an error will be reported.
1570+
1571+
To allow a BOM, use the `YYJSON_READ_ALLOW_BOM` or `YYJSON_READ_ALLOW_EXT_WHITESPACE` flags.
15581572
1559-
You can use `YYJSON_READ_ALLOW_INVALID_UNICODE` and `YYJSON_WRITE_ALLOW_INVALID_UNICODE` flags to allow invalid Unicode encoding. However, please note that if you enable these flags, the resulting values from yyjson may contain invalid characters, which could be used by other code and introduce security risks.
1573+
To allow invalid Unicode encoding, use the `YYJSON_READ_ALLOW_INVALID_UNICODE` and `YYJSON_WRITE_ALLOW_INVALID_UNICODE` flags. **Note:** Enabling these flags may result in yyjson producing values that contain invalid characters, which could be processed by other code and potentially introduce security risks.
15601574
1561-
You can use `yyjson_set_str_noesc(yyjson_val *val, bool noesc)` or `yyjson_mut_set_str_noesc(yyjson_mut_val *val, bool noesc)` to mark a string as not needing to be escaped during JSON writing. This will make string writing faster and preserve the original string bytes.
1575+
To mark a string as not requiring escaping during JSON writing, use `yyjson_set_str_noesc(yyjson_val *val, bool noesc)` or `yyjson_mut_set_str_noesc(yyjson_mut_val *val, bool noesc)`. This can improve string-writing performance and preserve the original string bytes.
15621576
15631577
## NUL Character
15641578
This library supports the `NUL` character (also known as the `null terminator`, or Unicode `U+0000`, ASCII `\0`) inside strings.

0 commit comments

Comments
 (0)