jl777
9 years ago
4 changed files with 78 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||
#include <stdio.h> |
|||
#include <stdint.h> |
|||
#include "../../includes/cJSON.h" |
|||
#include "../../crypto777/OS_portable.h" |
|||
|
|||
int32_t main(int32_t argc,char **argv) |
|||
{ |
|||
cJSON *filejson; char *fname,*filestr,*field; long filesize; int32_t n; |
|||
if ( argc > 2 ) |
|||
{ |
|||
fname = argv[1]; |
|||
field = argv[2]; |
|||
if ( (filestr= OS_filestr(&filesize,fname)) != 0 ) |
|||
{ |
|||
if ( (filejson= cJSON_Parse(filestr)) != 0 ) |
|||
{ |
|||
if ( jarray(&n,filejson,field) != 0 ) |
|||
printf("%s\n",jprint(jobj(filejson,field),0)); |
|||
free_json(filejson); |
|||
} else fprintf(stderr,"cant parse.(%s)\n",filestr); |
|||
free(filestr); |
|||
} else fprintf(stderr,"cant load (%s)\n",fname); |
|||
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]); |
|||
} |
|||
|
@ -0,0 +1,25 @@ |
|||
#include <stdio.h> |
|||
#include <stdint.h> |
|||
#include "../../includes/cJSON.h" |
|||
#include "../../crypto777/OS_portable.h" |
|||
|
|||
int32_t main(int32_t argc,char **argv) |
|||
{ |
|||
cJSON *filejson; char *fname,*filestr,*field; long filesize; |
|||
if ( argc > 2 ) |
|||
{ |
|||
fname = argv[1]; |
|||
field = argv[2]; |
|||
if ( (filestr= OS_filestr(&filesize,fname)) != 0 ) |
|||
{ |
|||
if ( (filejson= cJSON_Parse(filestr)) != 0 ) |
|||
{ |
|||
if ( jobj(filejson,field) != 0 ) |
|||
printf("%.8f\n",jdouble(filejson,field)); |
|||
free_json(filejson); |
|||
} else fprintf(stderr,"cant parse.(%s)\n",filestr); |
|||
free(filestr); |
|||
} else fprintf(stderr,"cant load (%s)\n",fname); |
|||
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]); |
|||
} |
|||
|
@ -0,0 +1,25 @@ |
|||
#include <stdio.h> |
|||
#include <stdint.h> |
|||
#include "../../includes/cJSON.h" |
|||
#include "../../crypto777/OS_portable.h" |
|||
|
|||
int32_t main(int32_t argc,char **argv) |
|||
{ |
|||
cJSON *filejson; char *fname,*filestr,*field; long filesize; |
|||
if ( argc > 2 ) |
|||
{ |
|||
fname = argv[1]; |
|||
field = argv[2]; |
|||
if ( (filestr= OS_filestr(&filesize,fname)) != 0 ) |
|||
{ |
|||
if ( (filejson= cJSON_Parse(filestr)) != 0 ) |
|||
{ |
|||
if ( jobj(filejson,field) != 0 ) |
|||
printf("%d\n",jint(filejson,field)); |
|||
free_json(filejson); |
|||
} else fprintf(stderr,"cant parse.(%s)\n",filestr); |
|||
free(filestr); |
|||
} else fprintf(stderr,"cant load (%s)\n",fname); |
|||
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]); |
|||
} |
|||
|
@ -1,2 +1,5 @@ |
|||
gcc -o jsoncmp jsoncmp.c ../../agents/libcrypto777.a -pthread -lm |
|||
gcc -o json_extract json_extract.c ../../agents/libcrypto777.a -pthread -lm |
|||
gcc -o json_extracti json_extracti.c ../../agents/libcrypto777.a -pthread -lm |
|||
gcc -o json_extractd json_extractd.c ../../agents/libcrypto777.a -pthread -lm |
|||
gcc -o json_extracta json_extracta.c ../../agents/libcrypto777.a -pthread -lm |
|||
|
Loading…
Reference in new issue