# Read all element of JSon httpPOST

**URL:** <https://community.smartthings.com/t/read-all-element-of-json-httppost/92636>\
**Category:** General Discussion\
**Tags:** developers\
**Created:** [July 13, 2017, 3:27pm UTC](https://community.smartthings.com/t/read-all-element-of-json-httppost/92636 "2017-07-13T15:27:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jems31](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@jems31](https://community.smartthings.com/u/jems31)\
**Post date:** [July 13, 2017, 3:27pm UTC](https://community.smartthings.com/t/read-all-element-of-json-httppost/92636/1 "2017-07-13T15:27:18Z")

</div>

Hello,

I work on a project of communication between an application android and a Smartapp.  
My application sends through an Https request a JSon of type:

{  
“ROOM0”: {  
“Name”: “kitchen”  
“Device1”: "thermos3"  
“Device0”: “Thermos4”  
}  
“Room1”: {  
“Name”: “livingroom”  
“Device1”: "thermos2"  
“Device0”: “thermos1”  
}  
}

I can recover the JSon Room0 and Room1 sparse, but I can not retrieve each element of my JSon afterwards.

My code:

mappings {  
path("/allheat") { action: [GET: “heatDevises”]}  
path("/changeheat") { action: [POST: “sendHeatCommands”]}  
path("/listRoom") { action: [POST: “listRoomGet”]}

Fonction:

def listRoomGet() {  
debug(“listRoomGet called”)

```
def Room01 = request.JSON?.Room0
def Room02 = request.JSON?.Room1

def results = [:]
results << [name1 : Room01] //{"Name": "kitchen","Device1": "thermos3","Device0": "Thermos4"}
results << [name2 : Room02] //{"Name": "living","Device1": "thermos2","Device0": "Thermos1"}

/*
def nameR = Room01.JSON?.Name
results << [name : nameR]
*/

render contentType: "text/json", data: new JsonBuilder(results).toPrettyString()

```

}

How can I recover my items separately?

---

<div class="post-metadata">

**Author:** ![jems31](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@jems31](https://community.smartthings.com/u/jems31)\
**Post date:** [July 14, 2017, 8:38am UTC](https://community.smartthings.com/t/read-all-element-of-json-httppost/92636/2 "2017-07-14T08:38:57Z")

</div>

Ok I’m Going to Sleep !!!

I find the solution …

def nameR = [Room01.Name](http://Room01.Name)

I’m null, I know ^^

---

<div class="post-metadata">

**Author:** ![ritchierich](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@ritchierich](https://community.smartthings.com/u/ritchierich)\
**Post date:** [July 14, 2017, 11:07am UTC](https://community.smartthings.com/t/read-all-element-of-json-httppost/92636/3 "2017-07-14T11:07:42Z")

</div>

Use JsonSlurper(). You can search Google for examples. Here is another thread with details too:

> [@Help Searching a JsonSlurper list](https://community.smartthings.com/t/help-searching-a-jsonslurper-list/20909):
>
> I’m trying to parse out the following json string: {"cid":"PWER","data":[{"1440023704000":0}],"sid":"123456","units":"kWm","age":142156},{"cid":"PWER\_GAC","data":[{"1440165858000":2202}],"sid":"123456","units":null,"age":2} Here is the code snip i’m using: def respData = summaryResp.data.text log.debug "Summary Reading Result: $summaryResp.data" log.debug "Summary text: ${respData}" def list = new JsonSlurper().parseText(respData) def cids = list.cid log.debug "Cid List: $cids" log.debug "List Values: $list" if(list.cid == "PWER\_GAC" && list.age \<= 10) clampType = "PWER\_GAC" log.debug "PWER\_GAC Data ${list.data}" log.debug "PWER\_GAC TimeStamp: ${list.data}" log.debug "PWER\_GAC Reading: ${list.data}" if(list.cid == "PWER" && list.age \<= 10) clampType = "PWER" …
