# Json for towns and shops

**URL:** <https://forum.playcanvas.com/t/json-for-towns-and-shops/5655>\
**Category:** Help & Support\
**Created:** [January 6, 2018, 8:33pm UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655 "2018-01-06T20:33:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayrin](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/ayrin/32/849_2.png) [@ayrin](https://forum.playcanvas.com/u/ayrin)\
**Post date:** [January 6, 2018, 8:33pm UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655/1 "2018-01-06T20:33:52Z")

</div>

Hello, i want to make a Json that list the shops in each town so i thought

```javascript
{ "towns" : [
    {"id":1, "name":"townName", "shops" : [
         {"Blacksmith":true, "x":1, "y":1, "z":1},
         {"Inn":true, "x":2, "y":2, "z": 2}
         ........
     ]
     }
     {"id:2, "name":"town2", ......
     }
]
}

```

is this type of json doable and if yes how do i access to Blacksmith parameters? Thanks

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [January 6, 2018, 11:12pm UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655/2 "2018-01-06T23:12:08Z")

</div>

`towns` is an array object so you can access the array of towns like so: `towns[i]`.

Within each object in that array, there is a property for shops which is also an array object that you can access like: `towns[i],shops[j]`.

So `towns[0].shops[0]` would return `{"Blacksmith":true, "x":1, "y":1, "z":1}`

---

<div class="post-metadata">

**Author:** ![ayrin](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/ayrin/32/849_2.png) [@ayrin](https://forum.playcanvas.com/u/ayrin)\
**Post date:** [January 6, 2018, 11:25pm UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655/3 "2018-01-06T23:25:40Z")

</div>

Thanks @yaustar i thought of semplify it in towns with id:1 Blacksmith:true …etc etc without the sub shops since i don’t really needed the town name but just the id 🙂

---

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [January 7, 2018, 1:04am UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655/4 "2018-01-07T01:04:07Z")

</div>

I probably wouldn’t do:

```javascript
"Blacksmith": true

```

Instead, I’d do:

```javascript
"type": "blacksmith"

```

---

<div class="post-metadata">

**Author:** ![ayrin](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/ayrin/32/849_2.png) [@ayrin](https://forum.playcanvas.com/u/ayrin)\
**Post date:** [January 9, 2018, 11:11am UTC](https://forum.playcanvas.com/t/json-for-towns-and-shops/5655/5 "2018-01-09T11:11:48Z")

</div>

I have used “Blacksmith”: true because if false it put an House instead a shop to not leave an empty space if just used “type”: “nameofshop” i couldn’t check if shop is present or not
