Skip to main content

Default UDT type conversion

Default UDT type conversion to JSON

Abstract

Default UDT type conversion to JSON

  • JSON strings are enclosed in quotation marks.

    They can be any length, but JSON parsers can typically parse strings that are up to 1MB in length.

  • JSON Boolean values

  • JSON dates and times

  • JSON numbers

S7 IEC data types

The Table 1, “Siemens S7 IEC data types to a default format in JSON maps Siemens S7 IEC data types to a default format in JSON.

Table 1. Siemens S7 IEC data types to a default format in JSON

S7 data type

JSON type

JSON format

BOOL

Boolean

true
false

BYTE

Integer

255
1
0

WORD

Integer

65535
1
0

DWORD

Integer

4294967296
1
0

INT

Integer

-32768
-1
0
1
32767

DINT

Integer

-2147483648
-1
0
1
2147483647

REAL

Integer

-9999999999
-1.0
-1
0
1
1.0
0.1
0.00000009

S5TIME (duration)

String

S5T#[n]H_[n]M_[n]S_[n]MS — for example, S5T#0H_1M_0S_0MS

TIME (duration)

String

T#[n]D_[n]H_[n]M_[n]S_[n]MS — for example, T#0D_1H_1M_0S_0MS
-T#[n]D_[n]H_[n]M_[n]S_[n]MS — for example, T#24D_24H_31M_23S_647MS

DATE

String

YYYY-MM-DD — for example, 2009-01-06

TIME_OF_DAY

String

hh:mm:ss.sss — for example, 16:01:59.001

CHAR

String

"some string"

Nested Arrays

Array of arrays

{
 "myArray": 
 [ 
   [1,2,3],  
   [4,5,6] 
 ]
}

Array of Values

Array of values

{
 "array1": [ 1,2,3 ],
 "array2": [ "A","B","C" ],
 "array3": [ "A",1, "B",2, "C",3 ]
}

Array of Objects

Array of objects

{
 "myArray": 
 [ 
   { "Label": "height", "Value": 1}  
 ]
}


Note

All of the types listed in Table 1, “Siemens S7 IEC data types to a default format in JSON have been tested extensively except S5TIME (duration), TIME (duration), DATE, and TIME_OF_DAY.  These four types are also supported, but they have not been tested.