Update cookies preferences
Promotic

JsonStringify - method of the Pm object

Description:
From input value creates text in the JSON format
Syntax:
String JsonStringify(Variant Value, [String Space])
Parameters:
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 not set (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 is number (1 to 10), then the text of return value has offset of defined number of spaces on each level.
If is non-empty string, for example tab (space:\t;) or two spaces, then the text of return value has offset by characters defined in the string on each level.
If the string is longer than 10 characters, then only the first 10 characters will be used.
Note:
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 to the beginning and to the end add quotation mark. 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: null for JavaScript or Empty for VBScript (it can be tested by the Pm.IsValid method).


This method is functional also in Macro expression $.expr and in the onDraw event of the PmgCanvas object.
This method is also functional in Web panels.
See also:
Example:
Creates the PmMap object, fills it with properties name and Val and saves this object into a text string in the JSON format.
JavaScriptVBScriptSelect and copy to clipboard

var sJson;
var mMap = Pm.CreatePmMap();

mMap.mapSetValueAt("name", "Temperature");
mMap.mapSetValueAt("val", 65.5);
sJson = Pm.JsonStringify(mMap);   // In the sJson variable there will be string: {"name":"Temperature","val":65.5}

History:
Pm9.00.26: Now functional also for 2-dimensional array in the PmArray object.
Pm8.03.13: Created
PROMOTIC 9.0.29 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- JsonStringify
 
 
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.