JsonStringify - method of object Pm

From input value creates text in JSON format
JsonStringify(Value As Variant, [Space As String]) As String
var sJson = Pm.JsonStringify(Value)
Value(Variant) Input value that is transformed into JSON format. The value can be:
- object of the PmMap type
- array of the PmArray type
- elementary data type (Integer, String, Boolean, Double ...)
Space[optional] (String) Adds return values of JSON offset to the text, space and end-row characters for easier reading.
If Space is omitted (or the semicolon is right after colon) then the text condensed without additional spaces (everything on single row without offset of levels of embedding).
If Space is number (1 to 10) then the text of return value has offset of defined number of spaces on each level.
If Space is non-empty string e.g. tab (space:\t;) or two spaces then the text of return value has offset by characters defined in string on each level.
If Space is longer than 10 characters then only the first ten characters will be used.
The value transformation procedure into JSON text is following:
- Number: It is transformed into text. The decimal separator is period.
- Boolean: It is transformed into text as true or false.
- String: It is transformed into text and inserted into quotation marks. If there is a quotation mark character in the string then it is transformed to two characters \".
- PmMap object: It is transformed into the form of JSON object. For example {"propery1":value1,"property2":value2}.
- PmArray object: It is transformed into the form of JSON array. For example [value1,value2].
- If the value type is other than those listed above then the method fails and returns Empty.
The method can also be called in the graphic item events for Web Panels.
Creates object PmMap, fills it with properties name and Val and saves this object into the string in JSON format.
Dim sJson, oMap
oMap.mapSetValueAt "name", "Temperature"
oMap.mapSetValueAt "val", 65.5
sJson2 = Pm.JsonStringify(oMap)
In variable sJson there will be string: {"name":"Temperature","val":65.5}.
- Pm
- Abs
- Cos
- E
- Exp
- JsonStringify
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice