Parse JSON file and create a copy of it

Hello, I am trying to create a copy of a JSON file that looks like that :

[
  {
    "id": "header",
    "inverLeft": true,
    "inverRight": false
  },
  {
    "id": 0,
    "linked": true,
    "comments": "First stereo filter",
    "left": {
      "central_frequency": 1000.0,
      "quality_factor": 2.0,
      "amplitude": 5.0,
      "filter_type": "low_pass",
      "bypass": false
    },
    "right": {
      "central_frequency": 1200,
      "quality_factor": 0.9,
      "amplitude": 5,
      "filter_type": "low_pass",
      "bypass": false
    }
  },
  {
    "id": 0,
    "linked": true,
    "comments": "second stereo filter",
    "left": {
      "central_frequency": 1000.0,
      "quality_factor": 2.0,
      "amplitude": 5.0,
      "filter_type": "low_pass",
      "bypass": false
    },
    "right": {
      "central_frequency": 1200,
      "quality_factor": 0.9,
      "amplitude": 5,
      "filter_type": "low_pass",
      "bypass": false
    }
  }
]

Basically it is a list of object, the first is a header, the others are stereo filters that contains individual right and left filters.

I want to be able to create a copy of it and export it too. For that I have a load function like so :

void BiquadChainAudioProcessor::loadFile(const juce::String& path)
{
    filePath = path;
    juce::File file(path);
    juce::String extension = file.getFileExtension();

    if (extension == ".json") {
        juce::String content = file.loadFileAsString();
        juce::var parsedJSON = juce::JSON::parse(content);
        copyJSON = parsedJSON;
        updateCoefficients();
        exportJSON("C:/Users/MyName/Documents/ExportedJSON_direct.json");
    }
}

with copyJSON being initialized as : juce::Array<juce::var> copyJSON;

I want to export it to verify if the loadFile function do it well :

void BiquadChainAudioProcessor::exportJSON(const juce::String& exportPath)
{
    juce::var jsonObject(copyJSON);
    juce::String jsonString = juce::JSON::toString(jsonObject);
    juce::File jsonFile(exportPath);
    jsonFile.replaceWithText(jsonString);
}

The thing is that the exported JSON looks like that :

[
  [
    {
      "id": "header",
      "inverLeft": true,
      "inverRight": false
    },
    {
      "id": 0,
      "linked": true,
      "comments": "First stereo filter",
      "left": {
        "central_frequency": 1000.0,
        "quality_factor": 2.0,
        "amplitude": 5.0,
        "filter_type": "low_pass",
        "bypass": false
      },
      "right": {
        "central_frequency": 1200,
        "quality_factor": 0.9,
        "amplitude": 5,
        "filter_type": "low_pass",
        "bypass": false
      }
    },
    {
      "id": 0,
      "linked": true,
      "comments": "second stereo filter",
      "left": {
        "central_frequency": 1000.0,
        "quality_factor": 2.0,
        "amplitude": 5.0,
        "filter_type": "low_pass",
        "bypass": false
      },
      "right": {
        "central_frequency": 1200,
        "quality_factor": 0.9,
        "amplitude": 5,
        "filter_type": "low_pass",
        "bypass": false
      }
    }
  ]
]

which is the data I want but in a nested list. There too ‘[[.]]’ instead of ‘[.]’. So naturally I tryied to take the element 0 of it when loading by modifying the function like so :

void BiquadChainAudioProcessor::loadFile(const juce::String& path)
{
    filePath = path;
    juce::File file(path);
    juce::String extension = file.getFileExtension();

    if (extension == ".json") {
        juce::String content = file.loadFileAsString();
        juce::var parsedJSON = juce::JSON::parse(content);
        copyJSON = parsedJSON[0];
        updateCoefficients();
        exportJSON("C:/Users/MyName/Documents/ExportedJSON_direct.json");
    }
}

But I end up with that :

[
  {
    "id": "header",
    "inverLeft": true,
    "inverRight": false
  }
]

which indeed is a list but it contains only the first element of the desired list.
So to summarize, either I have a list containing the list that I want or I have the first element of the list that I want. That is bugging me because I want the middle of that.

Thank you for any help, don’t hesitate to ask if I forgot something.

The issue here is that when I use the copyJSON it does not work as intended.
Like I would want to call copyJSON[1][“right”]. But it seems like the way I do just load either an array of 1 array, so copyJSON[1] does not exists, or an array with only the first element so copyJSON[1] does not exist neither and copyJSON[0][“right”] does not exist as copyJSON[0] is the header.