# Split string from app.getSelfPath

**URL:** <https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471>\
**Category:** General\
**Created:** [8 April 2025 10:20 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471 "2025-04-08T10:20:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SignalKuser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/signalkuser/32/100028_2.png) [@SignalKuser](https://discourse.nodered.org/u/SignalKuser)\
**Post date:** [8 April 2025 10:20 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/1 "2025-04-08T10:20:28Z")

</div>

hi,  
i want split a string comes from

```auto
let volt = app.getSelfPath('electrical.batteries.Mo.voltage');

```

the payload looks like

```auto
{"meta":{"units":"V","description":"Voltage measured at or as close as possible to the device"},"value":13.2,"$source":"jbd-overkill-bms-plugin","timestamp":"2025-04-08T10:14:51.566Z"}

```

but i only want "value":13.2  
how does it work?  
thx/christian

---

<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:** [8 April 2025 10:37 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/2 "2025-04-08T10:37:36Z")

</div>

Hi @SignalKuser

When you say the payload looks like that object, do you mean the value returned by `app.getSelfPath`?

Assuming that is the case, and assuming its an Object and not a String, then it looks like `volt.value` will get you to `13.2`.

However, if it is a String and not an Object, you will need to parse it to an Object first. You can do that by passing it through a JSON node, or if you want to stay inside a Function node, you can do `const data = JSON.parse(volt)` - then you can use `data.value`.

There's a section in the docs that gives some tips for working with messages - [Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)  
This includes how to pass messages to the debug sidebar and work out how to access individual properties.

---

<div class="post-metadata">

**Author:** ![SignalKuser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/signalkuser/32/100028_2.png) [@SignalKuser](https://discourse.nodered.org/u/SignalKuser)\
**Post date:** [8 April 2025 11:41 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/3 "2025-04-08T11:41:37Z")

</div>

> [@knolleary](#):
>
> const data = JSON.parse(volt)

its an openplotter image for raspi4. inside openplotter there is Signal K. and inside Signal K there is Node Red and KIP. KIP is my UI, there is a button and when i click the button Node Red should write something in a file. electrical.batteries.Mo.voltage is a Signal K path coming from a signal k plugin and how it looks the only chance to work with this signal k path in node red is with a function like this.

```auto
msg.filename ="/home/pi/test/hello.txt";
let app = global.get('app');
let volt = app.getSelfPath('electrical.batteries.Mo.voltage');
msg.payload = volt;

return msg;

```

the

```auto
const data = JSON.parse(volt) 

```

dont work:

```auto
function : (error)
"SyntaxError: Unexpected token o in JSON at position 1"

```

 ![node1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/0586251bbfa05a58ddb3330d4718312d45944134.png)  
 ![node2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d0ccaf8133fd9f3622f9930890fe12b288641b10.jpeg)

---

<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:** [8 April 2025 12:41 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/4 "2025-04-08T12:41:56Z")

</div>

Put a debug node on the output of the function node and show us what that shows.

---

<div class="post-metadata">

**Author:** ![SignalKuser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/signalkuser/32/100028_2.png) [@SignalKuser](https://discourse.nodered.org/u/SignalKuser)\
**Post date:** [8 April 2025 14:59 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/5 "2025-04-08T14:59:30Z")

</div>

WOW.  
yes, a debug node shows an object behind the function. now its easy to delete the other stuff. THANKS THANKS THANKS.

 ![debug2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e819c018f02d9ef79d35133a661cd1323320b210.jpeg)  
 ![kip1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f4227b089f9dab16b869390fa23043710390c5e.png)

---

<div class="post-metadata">

**Author:** ![SignalKuser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/signalkuser/32/100028_2.png) [@SignalKuser](https://discourse.nodered.org/u/SignalKuser)\
**Post date:** [8 April 2025 15:00 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/6 "2025-04-08T15:00:11Z")

</div>

![change1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52193e7aff84c10ad33ede5ea6fee9995b3b7c8f.jpeg)  
 ![rasp1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8c526bfc3603e6552180fc7762bdd55d4e70bc9e.jpeg)

---

<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 July 2025 15:00 UTC](https://discourse.nodered.org/t/split-string-from-app-getselfpath/96471/7 "2025-07-07T15:00:22Z")

</div>

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