# Working with JSON or XML

**URL:** <https://discourse.nodered.org/t/working-with-json-or-xml/53059>\
**Category:** General\
**Created:** [1 November 2021 11:06 UTC](https://discourse.nodered.org/t/working-with-json-or-xml/53059 "2021-11-01T11:06:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@brian](https://discourse.nodered.org/u/brian)\
**Post date:** [1 November 2021 11:06 UTC](https://discourse.nodered.org/t/working-with-json-or-xml/53059/1 "2021-11-01T11:06:25Z")

</div>

Hi all

A noob question

I have this unit that sends a JSON or XML file to a server which works fine (but a somewhat pricey solution) .

i would like to make a more simpel solution to this using node red.  
I know that it should work but i just need a direktion how to parse the file and send a response back to the unit.

any help would be appreciated

```auto
The JSON file structure:
{
 "Monitor": {
 "DeviceInfo": {
 "DeviceName": "TCG120",
 "HostName": "TCG120",
 "ID": "863071015406348",
 "FwVer": "v2.08",
 "MnfInfo": "www.teracomsystems.com",
 "SysContact": "info@teracomsystems.com",
 "SysName": "TCG120",
 "SysLocation": "Location"
 },
 "S": {
 "S1": {
 "description": "S1:TST1xx",
 "id": "28C4C109030000C5",
 "item1": {
 "value": "14.9",
 "unit": "°C",
 "alarm": "0",
 "min": "-40.0",
 "max": "85.0",
 "hys": "8.5"
 },
 "item2": {
 "value": "---",
 "unit": "---",
 "alarm": "0",
 "min": "---",
 "max": "---",
 "hys": "---"
 }
 },
 "S2": {
 "description": "S2:TSH2xx",
 "id": "015225B71700FF45",
 "item1": {
 "value": "22.6",
 "unit": "°C",
 "alarm": "0",
 "min": "-40.0",
 "max": "85.0",
 "hys": "8.5"
 },
 "item2": {
 "value": "57.9",
 "unit": "%RH",
 "alarm": "0",
 "min": "0.0",
 "max": "100.0",
 "hys": "10.0"
 }
 },
 "S3": {
 "description": "S3",
 "id": "0000000000000000",
 "item1": {
 "value": "---",
 "unit": "---",
 "alarm": "0",
 "min": "---",
 "max": "---",
 "hys": "---"
 },
TCG120 _R1.
1
6
- February 2021 Page 37
 "item2": {
 "value": "---",
 "unit": "---",
 "alarm": "0",
 "min": "---",
 "max": "---",
 "hys": "---
"

}
 },
 "S4": {
 "description": "S4",
 "id": "0000000000000000",
 "item1": {
 "value": "---",
 "unit": "---",
 "alarm": "0",
 "min": "---",
 "max": "---",
 "hys": "---
"
 },
 "item2": {
 "value": "---",
 "unit": "---",
 "alarm": "0",
 "min": "---",
 "max": "---",
 "hys": "---
"

}

}
 },
 "AI": {
 "AI1": {
 "description": "Analog Input 1",
 "value": "0.889",
 "unit": "V",
 "multiplier": "1.000",
 "offset": "0.0000",
 "alarm": "0",
 "min": "0.000",
 "max": "2.000",
 "hys": "0.500"
 },
 "AI2": {
 "description": "Analog Input 2",
 "value": "5.726",
 "unit": "V",
 "multiplier": "1.000",
 "offset": "0.0000",
 "alarm": "1",
 "min": "0.000",
 "max": "2.000",
 "hys": "0.500"

}
 },
 "DI": {
 "DI1": {
 "description": "Digital Input 1",
 "value": "OPEN",
 "valuebin": "1",
 "alarmState": "CLOSED",
 "alarm": "0"
 },
 "DI2": {
 "description": "Digital Input 2",
 "value": "OPEN",
 "valuebin": "1",
 "alarmState": "CLOSED",
 "alarm": "0"

}
TCG120 _R1.16 - February 2021 Page 38
 },
 "R": {
 "R1": {
 "description": "Relay 1",
 "value": "ON",
 "valuebin": "1",
 "pulseWidth": "5.0",
 "control": "0"
 },
 "R2": {
 "description": "Relay 2",
 "value": "ON",
 "valuebin": "1",
 "pulseWidth": "2.0",
 "control": "0"
 }
 },
 "HTTPPush": {
 "Key": "",
 "PushPeriod": "1"
 },
 "signalpercent": "80",
 "hwerr": "",
 "Alarmed": "1",
 "Scannig": "",
 "Time": {
 "Date": "05.02.2019",
 "Time": "12:11:02"
 },
 "NetworkInfo": {
 "Name": "Mobiltel EAD",
 "SC": {
 "MCC": "284",
 "MNC": "01",
 "LAC": "28200",
 "CID": "38449",
 "SQ": "-63"
 }
 }
 }
}

```

---

<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:** [1 November 2021 11:20 UTC](https://discourse.nodered.org/t/working-with-json-or-xml/53059/2 "2021-11-01T11:20:07Z")

</div>

Try reading the whole file in (not as separate lines) and feed it into a JSON node and see what comes out.

**[Edit]** Select Output Single UTF8 String in the file node.

---

<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:** [1 November 2021 11:26 UTC](https://discourse.nodered.org/t/working-with-json-or-xml/53059/3 "2021-11-01T11:26:11Z")

</div>

> [@brian](#):
>
> ```auto
> "hys": "---"
> },
> TCG120 _R1.
> 1
> 6
> - February 2021 Page 37
> "item2": {
> 
> ```

This section of the json does not look valid.

---

<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:** [31 December 2021 11:27 UTC](https://discourse.nodered.org/t/working-with-json-or-xml/53059/4 "2021-12-31T11:27:09Z")

</div>

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