# JSON File to 2D Array Java

**URL:** https://discourse.processing.org/t/json-file-to-2d-array-java/31414
**Category:** Coding Questions
**Created:** [July 24, 2021, 1:03am UTC](https://discourse.processing.org/t/json-file-to-2d-array-java/31414 "2021-07-24T01:03:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Gyrosis](https://avatars.discourse-cdn.com/v4/letter/g/aeb1de/32.png) [@Gyrosis](https://discourse.processing.org/u/Gyrosis)
#### Post date: [July 24, 2021, 1:03am UTC](https://discourse.processing.org/t/json-file-to-2d-array-java/31414/1 "2021-07-24T01:03:23Z")

</div>

How can I create a 2D array using a JSON file?  
“tile\_size”: 16,  
“map\_width”: 101,  
“map\_height”: 37,  
“layers”: [  
{  
“name”: “bg”,  
“positions”: [  
{ “x”:1, “y”:6, “id”:0 },  
{ “x”:1, “y”:7, “id”:0 },  
{ “x”:1, “y”:8, “id”:0 },  
{ “x”:1, “y”:9, “id”:0 },  
{ “x”:1, “y”:10, “id”:0 },  
{ “x”:1, “y”:11, “id”:0 },  
{ “x”:1, “y”:12, “id”:0 },  
{ “x”:1, “y”:13, “id”:0 },  
{ “x”:1, “y”:14, “id”:0 },  
{ “x”:1, “y”:15, “id”:0 },  
{ “x”:1, “y”:16, “id”:0 }  
]  
}  
]

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 24, 2021, 5:45am UTC](https://discourse.processing.org/t/json-file-to-2d-array-java/31414/2 "2021-07-24T05:45:07Z")

</div>

You can use methods **append()** or **setJSONArray()** to add a `new` JSONArray to your existing JSONArray:

- [Processing.org/reference/JSONArray\_append\_.html](http://Processing.org/reference/JSONArray_append_.html)
- [Processing.org/reference/JSONArray\_setJSONArray\_.html](http://Processing.org/reference/JSONArray_setJSONArray_.html)
