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.
aJsonObject* root = aJson.parse(songText);
aJsonObject* songData = aJson.getObjectItem(root, "songs");
aJsonObject* song = aJson.getArrayItem(songData, 0);
aJsonObject* songName = aJson.getObjectItem(song, "name");
songs[0].name = songName->valuestring;
aJsonObject* noteData = aJson.getObjectItem(song, "notes");
aJsonObject* timeData = aJson.getObjectItem(song, "times");
int numberNotes = aJson.getArraySize(noteData);
for (int i = 0; i < numberNotes; i++) {
aJsonObject* note = aJson.getArrayItem(noteData, i);
aJsonObject* time = aJson.getArrayItem(timeData, i);
songs[0].notes.push_back(note->valueint);
songs[0].notes.push_back(time->valueint);
}
aJsonObject* nunchuckData = aJson.getObjectItem(song, "nunchuck");
int numberNunchuck = aJson.getArraySize(nunchuckData);
for (int i = 0; i < numberNunchuck; i++) {
aJsonObject* note = aJson.getArrayItem(nunchuckData, i);
songs[0].nunchuck_notes.push_back(note->valueint);
}
And have been getting an empty string for the name, and usually identical random numbers for the other two. I am not sure what the issue is here, but I don't think it is memory as I had 651 bytes of memory remaining when I checked. Could it be the extra whitespace in the string?
Hi, I have been trying to parse this string using aJson
using this code
And have been getting an empty string for the name, and usually identical random numbers for the other two. I am not sure what the issue is here, but I don't think it is memory as I had 651 bytes of memory remaining when I checked. Could it be the extra whitespace in the string?