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

**URL:** https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417
**Category:** Coding Questions
**Created:** [September 25, 2021, 8:36pm UTC](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417 "2021-09-25T20:36:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![seanbetts](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seanbetts/32/14552_2.png) [@seanbetts](https://discourse.processing.org/u/seanbetts)
#### Post date: [September 25, 2021, 8:36pm UTC](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417/1 "2021-09-25T20:36:00Z")

</div>

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:

```auto
animal.setString("name", animalName);
animal.setString("description", "description of the animal");
animal.setString("image", imageURL);
animal.setJSONArray("attributes", animalAttributesArray);

```

This creates the following output:

```auto
{
	"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:

```auto
{
	"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!

---

<div class="post-metadata">

### Author: ![stevensrmiller](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stevensrmiller/32/14537_2.png) [@stevensrmiller](https://discourse.processing.org/u/stevensrmiller)
#### Post date: [September 25, 2021, 8:56pm UTC](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417/2 "2021-09-25T20:56:46Z")

</div>

> [@seanbetts](#):
>
> the output that should be created is with the first opening curly brace of the array on a new line

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.

---

<div class="post-metadata">

### Author: ![seanbetts](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/seanbetts/32/14552_2.png) [@seanbetts](https://discourse.processing.org/u/seanbetts)
#### Post date: [September 25, 2021, 9:17pm UTC](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417/3 "2021-09-25T21:17:09Z")

</div>

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!
