]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/jsmn/example/maptest.c
modified: src/lib/jsmn/example/MAPTEST.EXE
[16.git] / src / lib / jsmn / example / maptest.c
index ef9c4427a97a6d5a6371f1961e3463136178957d..3cbcab9bb482d4af5b440cc9dfd3c3489e0b0fba 100644 (file)
@@ -13,6 +13,7 @@
        "\"groups\": [\"users\", \"wheel\", \"audio\", \"video\"]}";*/
 
 char *JSON_STRING;
+char JSON_S[BUFSIZ];
 
 long int filesize(FILE *fp)\r
 {\r
@@ -38,21 +39,20 @@ int main() {
        int r;
        jsmn_parser p;
        FILE *fh = fopen("../../../../data/test.map", "r");
-       jsmntok_t t[1536]; /* We expect no more than 128 tokens */
-       char JSON_S[6144];
-       memset(JSON_S, 0, filesize(fh));
+       jsmntok_t t[2048]; /* We expect no more than 128 tokens */
+       //memset(JSON_S, 0, sizeof(JSON_S));
 
        if(fh != NULL)
        {
                fread(JSON_S, sizeof(char), filesize(fh), fh);
                // we can now close the file
-               fclose(fh); fh = NULL;
                //printf("]%s[\n", JSON_S);
                JSON_STRING=JSON_S;
                //printf("[[%s]]\n", JSON_STRING);
 
        jsmn_init(&p);
-       r = jsmn_parse(&p, JSON_STRING, strlen(JSON_STRING), t, sizeof(t)/sizeof(t[0]));
+       r = jsmn_parse(&p, JSON_STRING, filesize(fh), t, sizeof(t)/sizeof(t[0]));
+               fclose(fh); fh = NULL;
        printf("%s", JSON_STRING);
        if (r < 0) {
                printf("Failed to parse JSON: %d\n", r);