mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Include some analysis so that you can debug a failed parse.
You really oughtn't go too far with this, because it's only loose information; as I've said before, cJSON +isn't+ a validating parser. But this might give you enough info to save yourself on some rare occasion ;) git-svn-id: http://svn.code.sf.net/p/cjson/code@38 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
12
test.c
12
test.c
@@ -30,10 +30,14 @@ void doit(char *text)
|
||||
char *out;cJSON *json;
|
||||
|
||||
json=cJSON_Parse(text);
|
||||
out=cJSON_Print(json);
|
||||
cJSON_Delete(json);
|
||||
printf("%s\n",out);
|
||||
free(out);
|
||||
if (!json) {printf("Error before: [%s]\n",cJSON_GetErrorPtr());}
|
||||
else
|
||||
{
|
||||
out=cJSON_Print(json);
|
||||
cJSON_Delete(json);
|
||||
printf("%s\n",out);
|
||||
free(out);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read a file, parse, render back, etc. */
|
||||
|
Reference in New Issue
Block a user