aJson is an Arduino library to enable JSON processing with Arduino. It easily enables you to decode, create, manipulate and encode JSON directly from and to data structures.
adding class "aJsonFileStream" inherited from aJsonStream in order to backward- compatibility with HTTPClient library
Now is possible to operate directly with *FILE like streams, returned by HttpClient library and avoid intermediate buffering
Code example:
int getConfig()
{
FILE* result;
int returnCode ;
HTTPClient hclient("192.168.88.2",hserver,80);
result = hclient.getURI( FEED_URI);
returnCode = hclient.getLastReturnCode();
if (result!=NULL) {
if (returnCode==200) {
Serial.println("got Config :");
aJsonFileStream as=aJsonFileStream(result);
root = aJson.parse(&as);
hclient.closeStream(result); // this is very important -- be sure to close the STREAM
if (!root)
{
Serial.println("parseObject() failed");
return -11;
} else
{
char * outstr=aJson.print(root);
Serial.println(outstr);
items = aJson.getObjectItem(root,"items");
}
}
else {
Serial.print("ERROR: Server returned ");
Serial.println(returnCode);
return -11;
}
}
else {
Serial.println("failed to connect");
Serial.println(" try again in 5 seconds");
return -11;
}
return 2;
}
adding class "aJsonFileStream" inherited from aJsonStream in order to backward- compatibility with HTTPClient library Now is possible to operate directly with *FILE like streams, returned by HttpClient library and avoid intermediate buffering
Code example: