I have a struct I want to fill with Data from a JSON File with Arduinojson library. Filling the trackCount is no problem. Filling the tracks[] array is where I stuck. Struct:
struct AudioObject {
byte trackCount;
const char* tracks[];};
in setup():
AudioObject aO;
getAudioObject(jsonConfigFilename, &foo, &aO);
in function getAudioObject(const char* pConfigFilename, const String *paoID, AudioObject *aO):
File configFile = SD.open(pConfigFilename);
DynamicJsonDocument configDoc(4096);
DeserializationError error = deserializeJson(configDoc, configFile);
JsonArray arAudio= configDoc["toc"]["audioObject"];
for(JsonObject audioObject: arAudio) {
if(audioObject["audioId"]==*paoID){
//Found Audio ID Creating Object
aO->trackCount=(byte)audioObject["trackCount"];
//Now, lets get the Filenames
JsonArray arAudioTracks = audioObject["tracks"];
Serial.println (aO->trackCount);
//copy the Jsonarray to the AudioObject Array
copyArray(arAudioTracks,aO->tracks); // <---does not work
configDoc.clear();
configFile.close();
return true;
What am I doing wrong? I just want that aO->tracks contains the tracks stored in the jsonArray. Content is: ["filename1.mp3","filename2.mp3",...]