mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
add cJSON_Utils which includes JSON Pointer implementation
git-svn-id: svn://svn.code.sf.net/p/cjson/code@63 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
30
test_utils.c
Normal file
30
test_utils.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "cJSON_Utils.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
const char *json="{"
|
||||
"\"foo\": [\"bar\", \"baz\"],"
|
||||
"\"\": 0,"
|
||||
"\"a/b\": 1,"
|
||||
"\"c%d\": 2,"
|
||||
"\"e^f\": 3,"
|
||||
"\"g|h\": 4,"
|
||||
"\"i\\\\j\": 5,"
|
||||
"\"k\\\"l\": 6,"
|
||||
"\" \": 7,"
|
||||
"\"m~n\": 8"
|
||||
"}";
|
||||
|
||||
const char *tests[12]={"","/foo","/foo/0","/","/a~1b","/c%d","/e^f","/g|h","/i\\j","/k\"l","/ ","/m~0n"};
|
||||
|
||||
printf("JSON Pointer Tests\n");
|
||||
cJSON *root=cJSON_Parse(json);
|
||||
for (int i=0;i<12;i++)
|
||||
{
|
||||
printf("Test %d:\n%s\n\n",i+1,cJSON_Print(cJSONUtils_GetPointer(root,tests[i])));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user