# Function node injecting information with its quotes

**URL:** <https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665>\
**Category:** General\
**Created:** [24 May 2023 17:58 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665 "2023-05-24T17:58:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 17:58 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/1 "2023-05-24T17:58:50Z")

</div>

I am using a function node to grab information from a flow.xxx message. but it is pulling the quotes "[{ around the array causing it to read it as one entire item rather than an array. how do i prevent the function node from grabbing the quotes?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/11f5a1ecccc6e0e2c87d0e2b7e0095bc2fd754b4.png)

the image below is the current function node config

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e6015fb87c2ae48902e39186ba26b24d42235d91.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 May 2023 19:40 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/2 "2023-05-24T19:40:18Z")

</div>

Not clear where that data is coming from but it is a string representation of JSON data. You can pass it through a json node to get the actual data.

Or, in a function node, you can use `JSON.parse`. However, you should always wrap `JSON.parse` function calls in a `try {...} catch (err) {...}` wrapper because those functions fail in a nasty way.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 May 2023 19:45 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/3 "2023-05-24T19:45:12Z")

</div>

How are you setting the flow variable MDF?

---

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 19:46 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/4 "2023-05-24T19:46:49Z")

</div>

so when i run it through a json node, it turn back into an object, but then how do i get it into my function node for it to be represented in the data i need it in?

[{"a":"1","b":"0004a3fd2db9","c":"MDF Gi1/0/36"},{"a":"1","b":"P1\_EMP\_PARK\_L2","c":"MDF Gi1/0/24","d":"172.25.11.105"},{"a":"1","b":"P1\_EMP\_PARKS","c":"MDF Gi1/0/43","d":"172.25.11.103"},{"a":"1","b":"P1\_COFFEE\_ROOM","c":"MDF Gi1/0/7","d":"172.25.11.93"}]

when i put this data into the "items:" line it works just fine then changes the data into an object and has these items as an array properly

but when i pull the information through a referenced flow it pulls the data like this "[{"a":"1","b":"0004a3fd2db9","c":"MDF Gi1/0/36"},{"a":"1","b":"P1\_EMP\_PARK\_L2","c":"MDF Gi1/0/24","d":"172.25.11.105"},{"a":"1","b":"P1\_EMP\_PARKS","c":"MDF Gi1/0/43","d":"172.25.11.103"},{"a":"1","b":"P1\_COFFEE\_ROOM","c":"MDF Gi1/0/7","d":"172.25.11.93"}]" with quotes encapsulating the json array.

i dont really know how else to get this array into the referenced function node

---

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 19:48 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/5 "2023-05-24T19:48:43Z")

</div>

yes, flow.MDF gets populated when i run my ansible script.

---

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 19:49 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/6 "2023-05-24T19:49:55Z")

</div>

when i run the function node, it pulls the information from the flow variable, it just also encapsulates the data in quotes 😕

---

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 19:55 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/7 "2023-05-24T19:55:05Z")

</div>

i got it figured out. you were right about running it through the json file. but i had to first let it go into the flow node, recycle it self through a json file and reset the flow node.

for some reason if i sent it directly into the flow node as a json object it was just injecting the word object over and over.

---

<div class="post-metadata">

**Author:** ![tgottie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tgottie](https://discourse.nodered.org/u/tgottie)\
**Post date:** [24 May 2023 19:55 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/8 "2023-05-24T19:55:24Z")

</div>

you are awesome my man!! thank you 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 May 2023 20:18 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/9 "2023-05-24T20:18:00Z")

</div>

When it comes from Ansible it will be a string (that is what the quotes are telling you, the quotes are not really there it is just the way that a string is identified). Ideally you should send it through a JSON node when it comes in from Ansible, and use the result to set the flow variable, rather than setting the flow variable with a string and then trying to sort it out later.

---

<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:** [7 June 2023 20:18 UTC](https://discourse.nodered.org/t/function-node-injecting-information-with-its-quotes/78665/10 "2023-06-07T20:18:33Z")

</div>

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