Promotic
WikipediaLinkedInYoutubeTwitterFacebook

JsonParse - method of object Pm

Description:
Reads input text in JSON format and returns its binary representation in the form of objects (PmMap), arrays (PmArray) and values of elementary data types (Integer, String ...).
Syntax:
JsonParse(sJson As String) As PmMap
Calling:
var oMap = Pm.JsonParse(sJson)
Parameters:
sJson(String) String in JSON format.
Return Values:
The method returns object PmMap containing information regarding the completed transformation. The object has a single property:
 
Value: Data read from input text. The value can be represented by PmMap object, PmArray object, or value of elementary type.
Note:
Objects stored in JSON will be represented by PmMap objects, arrays stored in JSON will be represented by PmArray objects and other values stored in JSON will be represented by values of corresponding data type (Variant). This hierarchical data in object form can be easily accessed in PROMOTIC application either from JavaScript, or from VBScript.
 
The method can also be called in the graphic item events for Web Panels.
Example1:
Let there be a string in the sJson variable: [10, 20, 30, 40].

In oMap.Value there will be an PmArray type object.

Into the variable vVal1 is saved the value of array item with index 1 (value 20).

Dim oMap, oJson, vVal1
Set oMap = Pm.JsonParse(sJson)
Set oJson = oMap.Value
vVal1 = oJson.GetItem(1)
Example2:
Let there be a string in the sJson variable: {"position": {"x": 100, "y": 100}, "size": {"dx": 200, "dy": 100}}.

In oMap.Value there will be an PmMap type object.

Into the variable vValX is saved the value of property x (value 100).

Into the variable vValDx is saved the value of property dy (value 200).

Dim oMap, oJson, vValX, vValDx
Set oMap = Pm.JsonParse(sJson)
Set oJson = oMap.Value
vValX = oJson.position.x
vValDx = oJson.size.dx
Example3:
Let there be a string in the sJson variable: [{"x": 100, "y": 111}, {"x": 200, "y": 222}, {"x": 300, "y": 333}].

In oMap.Value there will be an PmArray type object.

Into the variable vValX is saved the value of property x of the item with index 1 (value 200).

Into the variable vValY is saved the value of property y of the item with index 1 (value 222).

Dim oMap, oJson, vValX, vValDx
Set oMap = Pm.JsonParse(sJson)
Set oJson = oMap.Value
vValX = oJson.GetItem(1).x
vValY = oJson.GetItem(1).y
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- JsonParse
 
 
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice