Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created July 3, 2014 18:04
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 TooTallNate/d1f8ee799e9764c0ab18 to your computer and use it in GitHub Desktop.
Save TooTallNate/d1f8ee799e9764c0ab18 to your computer and use it in GitHub Desktop.
var utility = ffi.Library('utility', {
'tesJson': ['void', ['string']]
});
var obj = {'1': 'one', '2': 'two'};
utility.tesJson(JSON.stringify(obj));
void tesJson(char *text) {
json_t *root;
size_t i;
json_error_t error;
root = json_loads(text, 0, &error);
for(i = 0; i < json_array_size(root); i++) {
json_t *data;
data = json_array_get(root, i);
printf("%s\n", json_string_value(data));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment