Skip to content

Docs: document embedded NUL round-trip limitation in parse/print - #1136

Open
YikunWei-dev wants to merge 1 commit into
DaveGamble:masterfrom
YikunWei-dev:docs/embedded-nul-print-limitation
Open

YikunWei-dev wants to merge 1 commit into
DaveGamble:masterfrom
YikunWei-dev:docs/embedded-nul-print-limitation

Conversation

@YikunWei-dev

Copy link
Copy Markdown

cJSON_ParseWithLength can parse strings that contain embedded NUL bytes (e.g. from "\u0000"), but strings are stored as NUL-terminated C strings without an explicit length. cJSON_Print therefore truncates at the first NUL, so parse -> print does not round-trip for such strings.

Document this limitation in cJSON.h (cJSON_ParseWithLength, cJSON_Print) and README, and add a regression test in tests/parse_with_opts.c that captures the documented behavior.

cJSON_ParseWithLength can parse strings that contain embedded NUL bytes
(e.g. from "\u0000"), but strings are stored as NUL-terminated C
strings without an explicit length. cJSON_Print therefore truncates at
the first NUL, so parse -> print does not round-trip for such strings.

Document this limitation in cJSON.h (cJSON_ParseWithLength,
cJSON_Print) and README, and add a regression test in
tests/parse_with_opts.c that captures the documented behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant