int main() { printf("Hello jansson...\n"); const char * data_str = "{\ \"operation\":\"mark-tier-movement\",\ \"mark_tier_movement_request\":{\ \"mark_tier_movement\":true\ }\ }"; json_t *root; json_error_t error; root = json_loads(data_str, 0, &error); if (!root) { printf("error: on line %d: %s\n", error.line, error.text); return 1; } json_t *operation; const char *msg_txt; operation = json_object_get(root, "operation"); msg_txt = json_string_value(operation); printf("operation is: %s\n", msg_txt); return 0; }
[root@localhost dev]# ./demo
Hello jansson...
operation code: is: mark-tier-movement