Working with JSON or XML

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

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"
 }
 }
 }
}

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.

This section of the json does not look valid.

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