cJSON icon indicating copy to clipboard operation
cJSON copied to clipboard

reject valid input when parsing json text

Open Dongmuliang opened this issue 3 years ago • 1 comments

Hi, we have encountered an error when attempting to parse a JSON text using the parser. However, we have checked the text against the JSON grammar specified in RFC 7159 and found it to be compliant (i.e., JSON parser MUST accept all texts that conform to the JSON grammar). Other JSON parsers, such as those found at jsonlint.com and github.com/nlohmann/json, were able to parse the text without issue.

Specifically, we use the following code to parse a json text:

const char *s = "{\"a\": true, \"b\": [ null,9999999999999999999999999999999999999999999999912345678901234567]}";
cJSON *root = NULL;

root = cJSON_Parse(s);
if (root == NULL) {
       const char *error_ptr = cJSON_GetErrorPtr();
       printf("error in json data:%s\n", error_ptr);
}

Dongmuliang avatar Dec 27 '22 15:12 Dongmuliang