0

How can i parse this json response after storing it as a char to get the strings and store them in variables? using any c library. Cjson probably because that's the one i am using to build the request..

{  

   "responseExitCode":"200",
   "message":"Account Created",
   "accountnumber":"58aa9f170c073",
   "accounttype":"Yea",
   "accountname":"Danstan Onyango"

}
BLUEPIXY
  • 39,699
  • 7
  • 33
  • 70
Danstan
  • 1,501
  • 1
  • 13
  • 20

1 Answers1

-1

If you have that data in a char * you can parse them. Just read the docs. Its there.

char *my_json_string = "{ "responseExitCode" ...";

cJSON * root = cJSON_Parse(my_json_string);

char *message = cJSON_GetObjectItem(root, "message")->valuestring;
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187