Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ cJSON doesn't support strings that contain the zero character `'\0'` or `\u0000`

cJSON only supports UTF-8 encoded input. In most cases it doesn't reject invalid UTF-8 as input though, it just propagates it through as is. As long as the input doesn't contain invalid UTF-8, the output will always be valid UTF-8.

cJSON also does not validate or reject unescaped control characters (bytes with a value below `0x20`, such as tab or newline) inside strings. Per the JSON specification these must be escaped (e.g. `\u0009` or `\u000A`), but cJSON copies them through verbatim for leniency. If you require strict rejection of unescaped control characters, you must validate the input yourself, either before parsing or by walking the resulting tree after parsing.

#### C Standard

cJSON is written in ANSI C (or C89, C90). If your compiler or C library doesn't follow this standard, correct behavior is not guaranteed.
Expand Down
5 changes: 4 additions & 1 deletion cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ CJSON_PUBLIC(const char*) cJSON_Version(void);
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);

/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate.
* Note: cJSON does not validate UTF-8 and does not reject unescaped control
* characters (bytes < 0x20) inside strings; such bytes are copied through
* verbatim. See the "Character Encoding" section in the README. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
Expand Down