setJSONArray should start a new line when inserting an array into a JSON object

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!

What makes you think so? The opening curly bracket you are talking about is valid JSON in either of the places you have shown it.

OpenSea was having issues processing it, but I think it’s managed to do it now - so don’t think it’s a problem anymore. I’ll close this down. Thanks for getting back to me though!