Created
October 3, 2012 01:30
-
-
Save rnix/3824400 to your computer and use it in GitHub Desktop.
Test libjson-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ldd test | |
linux-vdso.so.1 => (0x00007fffaf5ff000) | |
libjson-c.so.2 => /usr/local/lib/libjson-c.so.2 (0x00007ff4d7c29000) | |
libm.so.6 => /lib64/libm.so.6 (0x00007ff4d799c000) | |
libc.so.6 => /lib64/libc.so.6 (0x00007ff4d7609000) | |
/lib64/ld-linux-x86-64.so.2 (0x00007ff4d7e33000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
gcc -L/usr/local/lib /usr/local/lib/libjson-c.so -lm -o test testjson-c.c | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nm test | grep json_token | |
0000000000600bc0 B json_tokener_errors | |
U json_tokener_free | |
U json_tokener_new | |
U json_tokener_parse_ex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <json/json.h> | |
#include <json/json_object_private.h> | |
int main(int argc, char* argv[]) | |
{ | |
char *geojson = "{}"; //argv[1]; | |
json_tokener* jstok = json_tokener_new(); | |
json_object* poObj = json_tokener_parse_ex(jstok, geojson, -1); | |
if( jstok->err != json_tokener_success) | |
{ | |
char err[256]; | |
snprintf(err, 256, "%s (at offset %d)", json_tokener_errors[jstok->err], jstok->char_offset); | |
json_tokener_free(jstok); | |
} | |
json_tokener_free(jstok); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment