Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Syntax

Code Block
Result = SRP_JSONJson(Handle, "GETGet", Path)

Returns

A valid JSON Entity Handle if the descendant was found, 0 if not.

Parameters

ParameterDescription
HandleHandle to a JSON Entity. Required.
PathA formatted string indicating the desired descendant. Required.

Remarks

The GET Get service returns a JSON Entity Handle to a descendant entity somewhere within the current JSON Entity Handle. Handle must point to a JSON object or JSON array for this method to work. Otherwise, it just returns the entity's current value.

...

Code Block
MenuHandle = SRP_JSONJson(ObjectHandle, "GETGet", "menu")

If you want to get a child of menu (without having to get the menu handle first), you separate each member name with a period, like so:

Code Block
ItemsHandle = SRP_JSONJson(ObjectHandle, "GETGet", "menu.items")

If you want to get an element within an array, you use square brackets instead of periods. This is how we drill down directly to the twelfth element within the items array:

Code Block
ItemHandle = SRP_JSONJson(ObjectHandle, "GETGet", "menu.items[12]")

And this is how we get the handle to the "label" member of the second item in the items array:

Code Block
LabelHandle = SRP_JSONJson(ObjectHandle, "GETGet", "menu.items[2].label")
Note
This service always returns a JSON Entity Handle. If you know the descendant will be a String, Number, or Boolean type entity, you might prefer to use GETVALUEGetValue instead, which gets the value instead of the handle.

Example

Code Block
// Test parsing an existing JSON string and then drilling down into specific values
SampleJSON  = '{"menu": {'
SampleJSON := '    "header": "SVG Viewer",'
SampleJSON := '    "items": ['
SampleJSON := '        {"id": "Open"},'
SampleJSON := '        {"id": "OpenNew", "label": "Open New"},'
SampleJSON := '        null,'
SampleJSON := '        {"id": "ZoomIn", "label": "Zoom In"},'
SampleJSON := '        {"id": "ZoomOut", "label": "Zoom Out"},'
SampleJSON := '        {"id": "OriginalView", "label": "Original View"},'
SampleJSON := '        null,'
SampleJSON := '        {"id": "Quality"},'
SampleJSON := '        {"id": "Pause"},'
SampleJSON := '        {"id": "Mute"},'
SampleJSON := '        null,'
SampleJSON := '        {"id": "Find", "label": "Find..."},'
SampleJSON := '        {"id": "FindAgain", "label": "Find Again"},'
SampleJSON := '        {"id": "Copy"},'
SampleJSON := '        {"id": "CopyAgain", "label": "Copy Again"},'
SampleJSON := '        {"id": "CopySVG", "label": "Copy SVG"},'
SampleJSON := '        {"id": "ViewSVG", "label": "View SVG"},'
SampleJSON := '        {"id": "ViewSource", "label": "View Source"},'
SampleJSON := '        {"id": "SaveAs", "label": "Save As"},'
SampleJSON := '        null,'
SampleJSON := '        {"id": "Help"},'
SampleJSON := '        {"id": "About", "label": "About Adobe CVG Viewer..."}'
SampleJSON := '    ],'
SampleJSON := '    "testbool": "true",'
SampleJSON := '    "testint": "1234567890",'
SampleJSON := '    "testreal": "1234567890.987654321"'
SampleJSON := '}}'

 // Parse it, then grab the label of entity 12 within the items array
If SRP_JSONJson(ObjectHandle, "PARSEParse", SampleJSON) EQ "" then
   LabelHandle = SRP_JSONJson(ObjectHandle, "GETGet", "menu.items[12].label")
   SRP_JSONJson(ObjectHandle, "RELEASERelease")
end

See Also

GETVALUEGetValue