Json read

Hello, i try use a loop from json parsed but without success, i use version 5.

i try :

Parsed is :

{"gpio":1,"noboard":1,"state":0},{"gpio":1,"noboard":1,"state":1},{"gpio":1,"noboard":1,"state":1}

My loop is :

DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(payload);
json.printTo(Serial);
Serial.println();
if (json.success()) {
for (int i = 0; i < 3 ; i++) {
int state= json["state"].as() ;

  • Serial.println(state);*

  • }*

  • }*
    When show state variable, if first is 0 all 2 lines are 0
    Can anibody help me?

When you put your payload into the Assistant here you get syntax errors, to do what you want will need the payload to be defined as an array - something like below...

{"x":[ 
{"gpio":1,"noboard":1,"state":0},
{"gpio":1,"noboard":1,"state":1},
{"gpio":1,"noboard":1,"state":1}
]}

The Assistant will give you code examples of how to parse the array.

Hello Riva, nice TOPPP

:slight_smile:

silvaa:
Hello Riva, nice TOPPP

:slight_smile:

TOPPP?