arduino-libraries / Arduino_JSON

Official JSON Library for Arduino
GNU Lesser General Public License v2.1
151 stars 60 forks source link

Added a new Example : JSON Value Extractor #7

Closed Chester-King closed 1 year ago

Chester-King commented 4 years ago

Greetings,

This sketch demonstrates how to use some features of the Official Arduino JSON library to traverse through all the key value pair in the object and the nested objects. Can be very helpful when searching for a specific data in a key which is nested at multiple levels The sketch actually uses recursion to traverse all the keys in a given JSON.

Chester-King commented 4 years ago

Issue #6 is addressed in this PR. For instance assuming your hardware is getting some data from the cloud in JSON format. For example when we get data from firebase in JSON format. At times the only data we need to work with Temperature and Smoke and they both are at different levels of JSON. Let's say you have a JSON Object

{
sensor1:{
temp : 39,
humidity : 56
   },
MQ2:{
CO: 0.000234,
LPG: 0.000312.
Smoke: 0.0002
   }
}

And you need to buzz the Buzzer when Temp value is above 45 and Smoke value is above 0.001 So you can use the code in this PR to extract both the values from the entire JSON and write the logic for Buzzer accordingly

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.