<printvalue()>




#include <stdio.h>

#include <string.h>

#include "jsmn.h"




void printvalues(const char *json, jsmntok_t *t, int tokcount,int *keys){

int i,j=0;

for(i=0;i<=tokcount;i++){

if(i==keys[j]){

printf("[%d] value:  %.*s\n",j+1,t[i+1].end-t[i+1].start,json+t[i+1].start);

j++;

}

}

}


설명: 다음 함수는 key에 저장된 key token의 번호 데이터를 통해서 token의 위치와 같은 경우 (즉, key token인 경우) 출력하게 하는 함수이다.



    printvalues(JSON_STRING,t,r,keyarray);

    return EXIT_SUCCESS;

}

parsejson.c에 마지막 부분에 추가한 printvalues()함수이다




<Output>





+ Recent posts