# Add quotes to Json Value

**URL:** <https://discourse.nodered.org/t/add-quotes-to-json-value/50096>\
**Category:** General\
**Created:** [24 August 2021 06:48 UTC](https://discourse.nodered.org/t/add-quotes-to-json-value/50096 "2021-08-24T06:48:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Le-bo2d9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/le-bo2d9/32/46920_2.png) [@Le-bo2d9](https://discourse.nodered.org/u/Le-bo2d9)\
**Post date:** [24 August 2021 06:48 UTC](https://discourse.nodered.org/t/add-quotes-to-json-value/50096/1 "2021-08-24T06:48:41Z")

</div>

Hi I'm totally new to node-red and need some help  
I'm getting values of a flow sensor via MQTT

```auto
{"FlowRate":0.19,"TotalVolume":11354.25,"KValues":[{"Item1":19.0,"Item2":24.0},{"Item1":38.0,"Item2":61.0},{"Item1":57.0,"Item2":93.0},{"Item1":76.0,"Item2":128.0},{"Item1":95.0,"Item2":163.0},{"Item1":114.0,"Item2":196.0}],"created_at":"2021-08-24T06:38:01.7884747Z","ModuleType":"FLO","value":"11354.2","Address":104,"Name":"Pump_flow"}

```

I  
i need quotes on the value of the FlowRate 0,19

I have a switch function to get the value so I can send it to Domoticz via MQTT

```auto
switch (msg.topic) {

    case "Pool/RTD/add102/Pool_temp":
    msg.payload = {"command":"udevice","idx":1414,"nvalue":0,"svalue":msg.payload.value};
    var Pool_temp = msg.payload.value
    break;

    case "Pool/RTD/add103/Roof_temp":
    msg.payload = {"command":"udevice","idx":1413,"nvalue":0,"svalue":msg.payload.value};
    break;

    case "Pool/pH/add99/Pool_pH":
    msg.payload = {"command":"udevice","idx":1416,"nvalue":0,"svalue":msg.payload.value};
    break;
    
    case "Pool/ORP/add98/Pool_orp":
    msg.payload = {"command":"udevice","idx":1415,"nvalue":0,"svalue":msg.payload.value};
    break;

case "Pool/FLO/add104/Pump_flow":
    
    msg.payload = {"command":"udevice","idx":1436,"nvalue":0,"svalue":msg.payload.FlowRate};
    break;
    
}
return msg;

```

Can someone put me please on the right track?

Kind regards  
Koen

---

<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:** [24 August 2021 07:03 UTC](https://discourse.nodered.org/t/add-quotes-to-json-value/50096/2 "2021-08-24T07:03:51Z")

</div>

> [@Le-bo2d9](#):
>
> ` msg.payload = {"command":"udevice","idx":1436,"nvalue":0,"svalue":msg.payload.FlowRate}`

Since it is a number, you can use `.toString()`  
` msg.payload = {"command":"udevice","idx":1436,"nvalue":0,"svalue":String(msg.payload.FlowRate.toString())}`

Or, you can append `""`  
` msg.payload = {"command":"udevice","idx":1436,"nvalue":0,"svalue":String(msg.payload.FlowRate+"")}`

Or use the `String()` function  
` msg.payload = {"command":"udevice","idx":1436,"nvalue":0,"svalue":String(msg.payload.FlowRate)}`

---

<div class="post-metadata">

**Author:** ![Le-bo2d9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/le-bo2d9/32/46920_2.png) [@Le-bo2d9](https://discourse.nodered.org/u/Le-bo2d9)\
**Post date:** [24 August 2021 14:27 UTC](https://discourse.nodered.org/t/add-quotes-to-json-value/50096/3 "2021-08-24T14:27:45Z")

</div>

Hi Steve,

Thx for the solution.  
I have used the String(msg.payload.FlowRate). I had tied the tostring but didn't noticed the capilal S of string

---

<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 September 2021 14:28 UTC](https://discourse.nodered.org/t/add-quotes-to-json-value/50096/4 "2021-09-07T14:28:30Z")

</div>

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