# How to get json into a inject

**URL:** https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533
**Category:** General
**Created:** [3 March 2020 00:06 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533 "2020-03-03T00:06:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gbond](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbond/32/38851_2.png) [@gbond](https://discourse.nodered.org/u/gbond)
#### Post date: [3 March 2020 00:06 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/1 "2020-03-03T00:06:28Z")

</div>

I'm sure this should be easy but I just can't seem to get my head around this:-

[topic  
`switch` can be used to change device state. The message will be something like this: `{ topic: "switch", payload: { value: (1|0) } }`  
"]  
and this:-  
[{  
topic: "switch",  
payload: {  
value: 1  
}  
}]  
is what I am looking at but I just cant seem to get the inject node set up  
everything I have tried when I debug from the node, the Value no longer appears to be there

this is what I start with  
deviceId: "db1241be-ca6c-46d1-9606-9067fbc128ba"  
deviceType: "switch"  
name: "lounge colour2"  
value: 0

this is what I end up with  
deviceId: "db1241be-ca6c-46d1-9606-9067fbc128ba"  
deviceType: "switch"  
name: "lounge colour2"

(the value: no longer there)

I really hope this make sense to someone

---

<div class="post-metadata">

### Author: ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)
#### Post date: [3 March 2020 00:15 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/2 "2020-03-03T00:15:39Z")

</div>

Can you post what you've currently got in the inject node. I assume it will be something like:

```
{ value: 1 }

```

And the payload type will be set to JSON. I'm finding your question a bit difficult to follow.

---

<div class="post-metadata">

### Author: ![gbond](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbond/32/38851_2.png) [@gbond](https://discourse.nodered.org/u/gbond)
#### Post date: [3 March 2020 16:55 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/3 "2020-03-03T16:55:45Z")

</div>

that is what I thought but it does not seem to like it  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d5e84f9e7c9c61249f89f46809a3c9863e8b72b.png)  
keeps telling me bad string

what am i doing wrong?

---

<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: [3 March 2020 16:57 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/4 "2020-03-03T16:57:59Z")

</div>

Change it to:

```auto
{ "value": 1 }

```

JSON requires "quotes" around all strings.

---

<div class="post-metadata">

### Author: ![gbond](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbond/32/38851_2.png) [@gbond](https://discourse.nodered.org/u/gbond)
#### Post date: [3 March 2020 17:02 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/5 "2020-03-03T17:02:28Z")

</div>

Thanks you so much I think I was doing it after the : ("value:") doing it as you have shown has resolved it

I new it was me just could not see it!!!!

Thanks again

---

<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 March 2020 17:02 UTC](https://discourse.nodered.org/t/how-to-get-json-into-a-inject/22533/6 "2020-03-17T17:02:34Z")

</div>

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