# Convert data string to json

**URL:** <https://discourse.nodered.org/t/convert-data-string-to-json/78904>\
**Category:** General\
**Tags:** function-node\
**Created:** [2 June 2023 14:52 UTC](https://discourse.nodered.org/t/convert-data-string-to-json/78904 "2023-06-02T14:52:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [2 June 2023 14:52 UTC](https://discourse.nodered.org/t/convert-data-string-to-json/78904/1 "2023-06-02T14:52:30Z")

</div>

Hello,

Via an http API I receive a response in payload an string:

summary.Channel=0↵summary.EnteredSubtotal.Hour=0↵summary.EnteredSubtotal.Today=54↵summary.EnteredSubtotal.Total=119↵summary.EnteredSubtotal.TotalInTimeSection=54↵summary.ExitedSubtotal.Hour=0↵summary.ExitedSubtotal.Today=47↵summary.ExitedSubtotal.Total=114↵summary.ExitedSubtotal.TotalInTimeSection=47↵summary.InsideSubtotal.Total=0↵summary.RuleName=NumberStat↵summary.UTC=1685642403

But this is not exploitable. Why convert this an Json message ?

Thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 June 2023 16:11 UTC](https://discourse.nodered.org/t/convert-data-string-to-json/78904/2 "2023-06-02T16:11:36Z")

</div>

The low code way would be as below, everything after template node.  
[How to import a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

```auto
[{"id":"6197fde55e0e3097","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":3840,"wires":[["ef94ed694d00a32f"]]},{"id":"ef94ed694d00a32f","type":"template","z":"b9860b4b9de8c8da","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"summary.Channel=0\nsummary.EnteredSubtotal.Hour=0\nsummary.EnteredSubtotal.Today=54\nsummary.EnteredSubtotal.Total=119\nsummary.EnteredSubtotal.TotalInTimeSection=54\nsummary.ExitedSubtotal.Hour=0\nsummary.ExitedSubtotal.Today=47\nsummary.ExitedSubtotal.Total=114\nsummary.ExitedSubtotal.TotalInTimeSection=47\nsummary.InsideSubtotal.Total=0\nsummary.RuleName=NumberStat\nsummary.UTC=1685642403","output":"str","x":300,"y":3840,"wires":[["6661a58ea8caf583"]]},{"id":"6661a58ea8caf583","type":"csv","z":"b9860b4b9de8c8da","name":"","sep":"=","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"key,value","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":430,"y":3840,"wires":[["968cb24db98962f7","18ea408b8e2458ec"]]},{"id":"968cb24db98962f7","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"parts.type","pt":"msg","to":"object","tot":"str"},{"t":"set","p":"parts.key","pt":"msg","to":"payload.key","tot":"msg"},{"t":"change","p":"parts.key","pt":"msg","from":".","fromt":"str","to":"_","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":3840,"wires":[["32bc122e5d6425fb","18ea408b8e2458ec"]]},{"id":"18ea408b8e2458ec","type":"debug","z":"b9860b4b9de8c8da","name":"parts","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"parts","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":3880,"wires":[]},{"id":"32bc122e5d6425fb","type":"join","z":"b9860b4b9de8c8da","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":750,"y":3840,"wires":[["9ceeefcdef477eda"]]},{"id":"9ceeefcdef477eda","type":"debug","z":"b9860b4b9de8c8da","name":"debug 306","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":3980,"wires":[]}]

```

---

<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:** [16 June 2023 16:11 UTC](https://discourse.nodered.org/t/convert-data-string-to-json/78904/3 "2023-06-16T16:11:58Z")

</div>

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