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:
Dave Gamble
2011-03-02 21:22:57 +00:00
parent b5d57642c2
commit 6a58ba5285
3 changed files with 24 additions and 12 deletions

12
test.c
View File

@@ -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. */