Skip to content

Instantly share code, notes, and snippets.

@rnix
Created October 3, 2012 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnix/3824400 to your computer and use it in GitHub Desktop.
Save rnix/3824400 to your computer and use it in GitHub Desktop.
Test libjson-c
$ 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)
all:
gcc -L/usr/local/lib /usr/local/lib/libjson-c.so -lm -o test testjson-c.c
$ nm test | grep json_token
0000000000600bc0 B json_tokener_errors
U json_tokener_free
U json_tokener_new
U json_tokener_parse_ex
#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