# Extracting json body

**URL:** <https://community.homey.app/t/extracting-json-body/47759>\
**Category:** Developers\
**Created:** [May 24, 2021, 6:13pm UTC](https://community.homey.app/t/extracting-json-body/47759 "2021-05-24T18:13:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [May 24, 2021, 6:13pm UTC](https://community.homey.app/t/extracting-json-body/47759/1 "2021-05-24T18:13:38Z")

</div>

I have problems getting the information out of a json body.  
I tried jsonpath evaluator. The input i have is;  
{“energyDetails”:{“timeUnit”:“YEAR”,“unit”:“Wh”,“meters”:[{“type”:“Production”,“values”:[{“date”:“2020-01-01 00:00:00”,“value”:2189424.0}]}]}}

I want out of value the number 2189424.0

the solution from jsonpath is: $.energyDetails.meters.[value]

when i try this in homeyscript it doesn’t work;  
var body = await res.json();  
var body2 = body.energyDetails.meters.values[‘value’]

or

var body2 = body.energyDetails.meters.[‘value’]

the console gives as result; Undefined

Anyone a idea how to get the correct format?

---

<div class="post-metadata">

**Author:** ![johan\_bendz](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johan_bendz/32/10344_2.png) [@johan\_bendz](https://community.homey.app/u/johan_bendz)\
**Post date:** [May 24, 2021, 6:52pm UTC](https://community.homey.app/t/extracting-json-body/47759/2 "2021-05-24T18:52:09Z")

</div>

> [@Marcel\_Ubels](#):
>
> var body = await res.json();  
> var body2 = body.energyDetails.meters.values[‘value’]

console.log(res.energyDetails.meters[0].values[0].value);

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [May 24, 2021, 7:38pm UTC](https://community.homey.app/t/extracting-json-body/47759/3 "2021-05-24T19:38:44Z")

</div>

Great, works💪
