Example for cJSON

Post Reply
t90add
Posts: 4
Joined: Thu Nov 07, 2013 7:27 pm

Example for cJSON

Post by t90add » Wed Nov 27, 2013 5:30 pm

Hi,

Does anybody have an example on how to use cJSON to make an array from analogRead() ?


Something like this:

Code: Select all

aJsonObject *createMessage()
{
  aJsonObject *msg = aJson.createObject();

  int analogValues[6];
  for (int i = 0; i < 6; i++) {
    analogValues[i] = analogRead(i);
  }
  aJsonObject *analog = aJson.createIntArray(analogValues, 6);
  aJson.addItemToObject(msg, "analog", analog);

  return msg;
}


Thanks

Post Reply