# Having issue in decoding JSON

**URL:** <https://discourse.nodered.org/t/having-issue-in-decoding-json/16129>\
**Category:** General\
**Created:** [1 October 2019 06:38 UTC](https://discourse.nodered.org/t/having-issue-in-decoding-json/16129 "2019-10-01T06:38:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maria](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Maria](https://discourse.nodered.org/u/Maria)\
**Post date:** [1 October 2019 06:38 UTC](https://discourse.nodered.org/t/having-issue-in-decoding-json/16129/1 "2019-10-01T06:38:44Z")

</div>

I am receiving data from MQTT publisher and that data is in JSON format. I decoded data using JSON node and it is decoded but after that i need to access the values and insert that values in mysql database.

```auto
var msg1 = msg1.payload.TagData[0].Values.M6_Current_A;
return msg1;

```

i have JSON in this format

```auto
{"FormatId":"TagValues","ApiVersion":1,"CollectionId":5,"TagData":[{"Time":"2019-10-01T11:36:07.918+05:00","Values":{"M6_Current_A":9.1834094859526887e-41,"M6_Current_B":0,"M6_Current_C":0,"M6_Current_N":0,"M6_Current_Avg":0,"M6_Voltage_A_B":396,"M6_Voltage_B_C":398.80389404296875,"M6_Voltage_C_A":394.85699462890625,"M6_Voltage_L_L_Avg":397.1259765625,"M6_Voltage_A_N":228.4644775390625,"M6_Voltage_B_N":230.25553894042969,"M6_Voltage_C_N":229.00503540039062,"M6_Voltage_L_N_Avg":229.99998474121094,"M6_Active_Power_A":7.3468677186085834e-41,"M6_Active_Power_B":0,"M6_Active_Power_C":0,"M6_Active_Power_Total":0,"M6_Frequency":50.499996185302734,"M6_Wapda_KWH":0}}]}"

```

Your kind help is needed

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [1 October 2019 06:49 UTC](https://discourse.nodered.org/t/having-issue-in-decoding-json/16129/2 "2019-10-01T06:49:07Z")

</div>

Moved to general as it is a question.

msg1.x does not exist.

To get the value use:

```auto
m = msg.payload.TagData[0].Values.M6_Current_A
return {payload:m}

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 October 2019 06:52 UTC](https://discourse.nodered.org/t/having-issue-in-decoding-json/16129/3 "2019-10-01T06:52:59Z")

</div>

Hi @Maria

The title says you have a problem decoding JSON, but your question is about inserting into a database and no mention of problems with json.

Could you clarify what you have done and what exactly you want to do?

Have you looked at the mysql nodes available on [flows.nodered.org](http://flows.nodered.org)? What have you tried so far?
