# Removing " " from payload

**URL:** <https://discourse.nodered.org/t/removing-from-payload/12531>\
**Category:** General\
**Created:** [24 June 2019 05:25 UTC](https://discourse.nodered.org/t/removing-from-payload/12531 "2019-06-24T05:25:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 05:25 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/1 "2019-06-24T05:25:16Z")

</div>

Looking for a way to remove " " from a payload as when writing to a file it appears as {"s":"","orig":"","length":0}

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 June 2019 05:50 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/2 "2019-06-24T05:50:36Z")

</div>

I think you need to explain how you are writing it to a file.

I just sent a message to a file and it wasn't as you show it there.

Could you - please - drag select the nodes used then in the top right corner of the window (where the three black/white lines depicting the menu) select export and then past to clipboard.

Then reply to this but before pasting the clipboard, type three ` letters. (Top left to the left of the number 1) then at the end enter another three of them.

That will make it nicer for people to see/access the code.

Then someone may look at it and reply.

Maybe a screen shot too of what the flow looks like.

That's usually pressing the key then dragging the picture into your reply.

---

<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 June 2019 06:18 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/3 "2019-06-24T06:18:24Z")

</div>

Send the data that you are writing to the file to a debug node and post it here so we can see what you are writing.  
Show us what you see in the file and tell us what you want there.

---

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 06:19 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/4 "2019-06-24T06:19:29Z")

</div>

No problemo will do once I'm at the pc and it's been rolling around in my head thought I'd throw it out there for a quick win but obv more info is required

---

<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:** [24 June 2019 06:23 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/5 "2019-06-24T06:23:27Z")

</div>

Well at the moment it looks like valid JSON, so could be re-imported somewhere else fairly easily. Removing the quotes would make it invalid, so yes we need to see how you really want it to be.

---

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 08:42 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/6 "2019-06-24T08:42:26Z")

</div>

So to go into a bit more depth, I am connecting to a PPPoE router, running a command, i redacted the info from it for these nodes because of security, this presents me with a list of ppp sessions, I need to then remove the text i dont require, i'm positive theres a cleaner way to do this anyway but i am still learning so stay with me, and if you can advise of a better way im all ears, anyway so after the removal and the extraction im left with the payload coming out like this

![payload](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1a043668e13a098edc3690e6e6e8c63ddf42b027.png)

flow looks like the following

 ![Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b8509269806051de1a1a4c9aeb595f40796c5d37.png)

`[{"id":"df68bd0c.63e53","type":"tab","label":"PPP Sessions","disabled":false,"info":""},{"id":"1ff4070e.5c5d39","type":"debug","z":"df68bd0c.63e53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1398.430419921875,"y":294.3611145019531,"wires":[]},{"id":"4a19772b.7bfe4","type":"inject","z":"df68bd0c.63e53","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":159.5,"y":270,"wires":[["259e6ec.7548b92"]]},{"id":"267977cb.0df858","type":"bigssh","z":"df68bd0c.63e53","name":"Command","commandLine":"ppp secret print detail without-paging;","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"ascii","payloadIsArg":true,"myssh":"4475ae29.a516e8","x":309.7593078613281,"y":422.5370788574219,"wires":[["76b18631.d9633"],["76b18631.d9633"],["76b18631.d9633"]]},{"id":"7a313f31.d65cb","type":"file","z":"df68bd0c.63e53","name":"","filename":"bbgnsimple.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1376.1259765625,"y":402.50933837890625,"wires":[[]]},{"id":"76b18631.d9633","type":"split","z":"df68bd0c.63e53","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":true,"addname":"payloadre","x":572.0703735351562,"y":388.78704833984375,"wires":[["72287df2.97a71c"]]},{"id":"72287df2.97a71c","type":"change","z":"df68bd0c.63e53","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"[\\r\\n]+","fromt":"re","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\" \"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":663.0703125,"y":336.6202697753906,"wires":[["26e07608.87579a"]]},{"id":"259e6ec.7548b92","type":"ui_button","z":"df68bd0c.63e53","name":"","group":"ef9fb293.7ef02","order":1,"width":0,"height":0,"passthru":false,"label":"Basic","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":299.0369873046875,"y":328.5647888183594,"wires":[["267977cb.0df858"]]},{"id":"26e07608.87579a","type":"string","z":"df68bd0c.63e53","name":"Extract BBGN Custo","methods":[{"name":"getRightMost","params":[{"type":"str","value":";;;"}]},{"name":"trimLeft","params":[]},{"name":"getRightMost","params":[{"type":"str","value":"name="}]},{"name":"delRightMost","params":[{"type":"str","value":"service"}]},{"name":"getRightMost","params":[{"type":"str","value":"profile="}]},{"name":"strip","params":[{"type":"str","value":"\"\""}]},{"name":"delRightMost","params":[{"type":"str","value":"bytes-out=0 last-logged-out=jan/01/1970 00:00:00"}]},{"name":"delRightMost","params":[{"type":"str","value":"remote"}]},{"name":"delRightMost","params":[{"type":"str","value":"limit-bytes-in=0"}]},{"name":"getRightMost","params":[{"type":"str","value":"limit-"}]},{"name":"delRightMost","params":[{"type":"str","value":"routes="}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":839.75,"y":441.0000305175781,"wires":[["17b2f7a5.5337e8"]]},{"id":"17b2f7a5.5337e8","type":"string","z":"df68bd0c.63e53","name":"Extract BBGN Custo pt2 ","methods":[{"name":"delRightMost","params":[{"type":"str","value":"bytes"}]},{"name":"delRightMost","params":[{"type":"str","value":"last-"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1010.25,"y":340.5000305175781,"wires":[["699ba08f.c764e"]]},{"id":"699ba08f.c764e","type":"change","z":"df68bd0c.63e53","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"[\\r\\n]+","fromt":"re","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1256,"y":488.0000305175781,"wires":[["7a313f31.d65cb","1ff4070e.5c5d39"]]},{"id":"4475ae29.a516e8","type":"SSH_Credentials","z":"","host":"xx.xx.xx.xx","port":"xx","userlabel":"username@xx.xx.xx.xx"},{"id":"ef9fb293.7ef02","type":"ui_group","z":"","name":"PPP","tab":"4523497c.b1a5c","disp":true,"width":"6","collapse":false},{"id":"4523497c.b1a5c","type":"ui_tab","z":"","name":"PPP Reporting","icon":"dashboard","order":1,"disabled":false,"hidden":false}]`

---

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 08:43 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/7 "2019-06-24T08:43:08Z")

</div>

if i cat the file in my ubuntu the text file it looks like the following

![text](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9597d3757003300dc2fb4e38ce959ed10fc19d2c.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [24 June 2019 08:54 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/8 "2019-06-24T08:54:51Z")

</div>

As @dceejay suggested, it looks like JSON.

If it is you can use the `JSON` node to convert it to a javascript object. Try it and see by linking a `JSON` to a `DEBUG` node and see what is returned in the debug panel.

---

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 10:27 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/9 "2019-06-24T10:27:05Z")

</div>

if i send it through a JSON node then i get the response as {"s":"","orig":"","length":0}

stranger still if i save as a CSV i get the below

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9d41eb0b1fe2eb1940db1beaf569689da06be58d.png)

---

<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 June 2019 10:32 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/10 "2019-06-24T10:32:50Z")

</div>

You have shown us what you get in the file but not what you want there.

---

<div class="post-metadata">

**Author:** ![Weespies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/weespies/32/9171_2.png) [@Weespies](https://discourse.nodered.org/u/Weespies)\
**Post date:** [24 June 2019 10:37 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/11 "2019-06-24T10:37:06Z")

</div>

I am looking to simply get a unique identifier which is referenced as "bbgnxxxxxx.b4bisp"

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

if i look at the file pre stipped it looks like the following ( info redacted )

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

---

<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:** [24 June 2019 10:40 UTC](https://discourse.nodered.org/t/removing-from-payload/12531/12 "2019-06-24T10:40:27Z")

</div>

From your most recent screenshot, you have `msg.payload` set to a Object with a property called `bbgn` with a value of `bbgnxxxxxx.b4bisp`.

Is your goal to just have `bbgnxxxxxx.b4bisp` written to the file by itself?

The File Out node writes whatever `msg.payload` you pass it. If you pass it an Object, it will JSON encode it before writing to the file.

If you just one it to write one value from that object, you can use a Change node to set `msg.payload` to the value of `msg.payload.bbgn` before passing it to the File node.
