I am trying to output a JSON file from my code which include some JSON objects and also a JSON array but the JSON array is not starting on a new line in the output JSON file, which causes problems when using the file.
Currently my code is as follows:
animal.setString("name", animalName);
animal.setString("description", "description of the animal");
animal.setString("image", imageURL);
animal.setJSONArray("attributes", animalAttributesArray);
This creates the following output:
{
"name": "Animal 1",
"description": "Animal 1 description",
"image": "Animal Image URL",
"attributes": [{
"trait_type": "Colour",
"value": "Black"
},
{
"trait_type": "Legs",
"value": "4"
},
{
"trait_type": "Species",
"value": "Bear"
}
]
}
However, the output that should be created is with the first opening curly brace of the array on a new line:
{
"name": "Animal 1",
"description": "Animal 1 description",
"image": "Animal Image URL",
"attributes": [
{
"trait_type": "Colour",
"value": "Black"
},
{
"trait_type": "Legs",
"value": "4"
},
{
"trait_type": "Species",
"value": "Bear"
}
]
}
I’m not sure if this is a bug or whether there’s a way I can force each object in the array to start on a new line?
Thanks in advance for any help you can give!