# How to convert json

**URL:** https://discourse.nodered.org/t/how-to-convert-json/47515
**Category:** General
**Created:** [23 June 2021 08:25 UTC](https://discourse.nodered.org/t/how-to-convert-json/47515 "2021-06-23T08:25:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ketpa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ketpa/32/42496_2.png) [@ketpa](https://discourse.nodered.org/u/ketpa)
#### Post date: [23 June 2021 08:25 UTC](https://discourse.nodered.org/t/how-to-convert-json/47515/1 "2021-06-23T08:25:44Z")

</div>

I'm use json  
 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/ee0308328d10127b0d315a0e593d746deabd530d.png) and it give me json like this

```auto
{
    "0": {
        "id": 1,
        "Address": 16401,
        "Name": "EE_Time_Cfg_i_TimeZoneOffset",
        "val": 0,
        "Default1": "60",
        "Unit": "min",
        "Description": "Przesuniecie czasu wzgledem UTC"
    },
    "1": {
        "id": 2,
        "Address": 16402,
        "Name": "EE_Time_Cfg_x_DST_Enable",
        "val": 0,
        "Default1": "1",
        "Unit": null,
        "Description": "Autoasu"
    },
    "2": {
        "id": 3,
        "Address": 16403,
        "Name": "EE_Time_Cfg_x_SNTP_Enable",
        "val": 0,
        "Default1": "0",
        "Unit": null,
        "Description": "Auttu"
    }
}

```

but I want like this

```auto
`[
  {
    "userId": 1,
    "id": 1,
    "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
    "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
  },
  {
    "userId": 1,
    "id": 2,
    "title": "qui est esse",
    "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
  }
}
]

```

How to do that?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 June 2021 09:00 UTC](https://discourse.nodered.org/t/how-to-convert-json/47515/2 "2021-06-23T09:00:13Z")

</div>

Where are you getting the data that goes to the json node? From looking at what you have and what you want, you are not inputing the correct data.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [23 June 2021 10:08 UTC](https://discourse.nodered.org/t/how-to-convert-json/47515/3 "2021-06-23T10:08:19Z")

</div>

Indeed there is no obvious mapping from one to the other... but maybe a simple function node with

```auto
msg.payload = Object.values(msg.payload);
return msg;

```

will be close enough

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 August 2021 10:09 UTC](https://discourse.nodered.org/t/how-to-convert-json/47515/4 "2021-08-22T10:09:05Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
