# Object vs strings - extract a value from a split

**URL:** <https://discourse.nodered.org/t/object-vs-strings-extract-a-value-from-a-split/42112>\
**Category:** General\
**Created:** [5 March 2021 18:34 UTC](https://discourse.nodered.org/t/object-vs-strings-extract-a-value-from-a-split/42112 "2021-03-05T18:34:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 March 2021 18:45 UTC](https://discourse.nodered.org/t/object-vs-strings-extract-a-value-from-a-split/42112/2 "2021-03-05T18:45:47Z")

</div>

You need to understand the differnece (and advantage) of using objects and properties in node-red (and JavaScript in general).

For example, if you have an object, there is ZERO need to split strings etc.

JSON stands for JavaScript Object Notation - meaning it is a string representation of a JS object - which is useful for transmitting between devices and across the internet (they all do strings right!). That is why JSON is so popular - because it is _REALLY EASILY_ convert to/from object/string.

So, when your data is a string, you have to split and mess about with it. Worse still if you want to change a value.

  

So the simple way to deal with JSON strings is to use a JSON node to convert the JSON string to a JS object. Or in you case, switch the inject to JSON mode ...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/8/186a3c505262be4a54c1824d5210934068136983.png)

--- ↑ change to ↓ ---

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

  

then it is childs play grabing (or changing) any of the values you want...

 ![lj2h5HBf8h](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f919d112155e8d7557ba849d740f3a5f3755e97b.gif)

* * *

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

_[View the full topic](https://discourse.nodered.org/t/object-vs-strings-extract-a-value-from-a-split/42112)._
