From: sparky4 Date: Thu, 19 Mar 2015 14:25:10 +0000 (-0500) Subject: new file: src/lib/jsmn/example/MAPTEST.EXE X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=7d95303658886687f8e2e9e35a7b078b4ea6c4ee;p=16.git new file: src/lib/jsmn/example/MAPTEST.EXE modified: src/lib/jsmn/example/maptest.c --- diff --git a/src/lib/jsmn/example/MAPTEST.EXE b/src/lib/jsmn/example/MAPTEST.EXE new file mode 100644 index 00000000..0a1ea860 Binary files /dev/null and b/src/lib/jsmn/example/MAPTEST.EXE differ diff --git a/src/lib/jsmn/example/maptest.c b/src/lib/jsmn/example/maptest.c index ca2902b5..787b9c2b 100644 --- a/src/lib/jsmn/example/maptest.c +++ b/src/lib/jsmn/example/maptest.c @@ -1,5 +1,6 @@ #include #include +#include #include "../jsmn.c" /* @@ -7,9 +8,9 @@ * tokens is predictable. */ -const char *JSON_STRING = +/*char *JSON_STRING = "{\"user\": \"johndoe\", \"admin\": false, \"uid\": 1000,\n " - "\"groups\": [\"users\", \"wheel\", \"audio\", \"video\"]}"; + "\"groups\": [\"users\", \"wheel\", \"audio\", \"video\"]}";*/ static int jsoneq(const char *json, jsmntok_t *tok, const char *s) { if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start && @@ -23,10 +24,19 @@ int main() { int i; int r; jsmn_parser p; - jsmntok_t t[128]; /* We expect no more than 128 tokens */ + jsmntok_t t[8192]; /* We expect no more than 128 tokens */ + char *JSON_STRING; + FILE *fh = fopen("../../../../data/test.map", "r"); + if(fh != NULL) + { + fread(JSON_STRING, sizeof(t), sizeof(t), fh); + // we can now close the file + fclose(fh); fh = NULL; + printf("%s\n", JSON_STRING); jsmn_init(&p); r = jsmn_parse(&p, JSON_STRING, strlen(JSON_STRING), t, sizeof(t)/sizeof(t[0])); + printf("%s\n", JSON_STRING); if (r < 0) { printf("Failed to parse JSON: %d\n", r); return 1; @@ -71,5 +81,10 @@ int main() { JSON_STRING + t[i].start); } } + + free(JSON_STRING); + } + if (fh != NULL) fclose(fh); + //} return 0; }