jeudi 26 février 2015

Extracting JSON text from char response buffer



I receive a large chunk of text from my Wi-Fi module.


Which is saved in my response buffer.



char wifiResponseBuffer[500];


The contents can be seen below :



AT+CIPSEND=84

> GET http://ift.tt/1vCZevU
SEND OK

+IPD,308:{"data":[{"line1":" Facebook Note ","line2":"Nathan Weighill also","line3":" commented on Harry ","line4":" Bailey's photo.","beep":1,"received_time":1424976639},{"line1":" Gmail Message ","line2":"","line3":"Noteu Error","line4":"","beep":1,"received_time":1424976640}],"summary":{"note_count":2}}
OK

OK
Unlink


I have a JSON parser library however need to extract the actual JSON text from the response before it can be parsed. This is at the first occurrence of { and last occurrence of }. What combination of string functions can I use in C to find the indexes of these characters and then extract the JSON text.


Any help is greatly appreciated,


Jack




Aucun commentaire:

Enregistrer un commentaire