# Convert object in array

**URL:** <https://discourse.nodered.org/t/convert-object-in-array/45870>\
**Category:** General\
**Created:** [18 May 2021 16:58 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870 "2021-05-18T16:58:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [18 May 2021 16:58 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/1 "2021-05-18T16:58:01Z")

</div>

Hi Friends!

I am receiving a message that I configured on my mikrotik but I am not able to work on the arguments to separate the information such as link, operator and status.  
I have tried with the flow jsonata, change and through function using "Object" and "valuesToArray" but I was not successful.

Below is a print and the code of my flow:

```auto
[{"id":"23cba95.bb3a756","type":"debug","z":"c109e6a1.40a078","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":140,"wires":[]},{"id":"c5de5e56.8021e","type":"http in","z":"c109e6a1.40a078","name":"RB_POST","url":"/pmkt","method":"post","upload":false,"swaggerDoc":"","x":550,"y":140,"wires":[["6ba8477b.48d418","b8203ea9.27803"]]},{"id":"6ba8477b.48d418","type":"function","z":"c109e6a1.40a078","name":"convert","func":"var stat = \"\";\nstat = msg.payload.mensagem;\nmsg.payload = stat;\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":140,"wires":[["23cba95.bb3a756"]]},{"id":"b8203ea9.27803","type":"http response","z":"c109e6a1.40a078","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":570,"y":80,"wires":[]}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a99204600c2fce72c55b6679ca2a5f0455c87c9.png)

I appreciate if you can help me solve this case!

---

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [18 May 2021 17:14 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/2 "2021-05-18T17:14:50Z")

</div>

In time, the output follows when I try to use the "**msg.payload = Object.values (stat);**"

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/94e419c9f9f741cd87524cc6f5c6f3cd94918a2b.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 May 2021 17:14 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/3 "2021-05-18T17:14:55Z")

</div>

You can pass it through a json node to convert the json string to an object.

But I have to ask what does the url look like as if you send `http://ip:1880/pmkt?link=wan_1&operadora=vivo&status=down` you should get the object not a json string

---

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [18 May 2021 17:18 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/4 "2021-05-18T17:18:19Z")

</div>

Thanks @ E1cid!

I will try this way, because as I am following a step by step of mikrotik I used the format 'http-data'.  
I'm going to do a test right now and then return the result.

---

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [18 May 2021 22:37 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/5 "2021-05-18T22:37:28Z")

</div>

Unfortunately it does not work in Mikrotik create query via url ...  
You can't even type in the "?" to start building the query.

This was the Mikrotik documentation that I followed:  
[Mikrotik Tools/Fetch URL](https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 May 2021 22:48 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/6 "2021-05-18T22:48:19Z")

</div>

Ok, but did you try the first suggestion, passing the payload through a json node?

---

<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:** [17 July 2021 22:49 UTC](https://discourse.nodered.org/t/convert-object-in-array/45870/7 "2021-07-17T22:49:13Z")

</div>

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