Page History
...
The term descendant is intentional because you can extract members or elements deep within the JSON tree in a single call. Let's use the following JSON as an example:
Code Block |
---|
{"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, {"id": "OpenNew", "label": "Open New"}, null, {"id": "ZoomIn", "label": "Zoom In"}, {"id": "ZoomOut", "label": "Zoom Out"}, {"id": "OriginalView", "label": "Original View"}, null, {"id": "Quality"}, {"id": "Pause"}, {"id": "Mute"}, null, {"id": "Find", "label": "Find..."}, {"id": "FindAgain", "label": "Find Again"}, {"id": "Copy"}, {"id": "CopyAgain", "label": "Copy Again"}, {"id": "CopySVG", "label": "Copy SVG"}, {"id": "ViewSVG", "label": "View SVG"}, {"id": "ViewSource", "label": "View Source"}, {"id": "SaveAs", "label": "Save As"}, null, {"id": "Help"}, {"id": "About", "label": "About Adobe CVG Viewer..."} ] }} |
...
In this example, we have a root object with a single child object called "menu" as it's only member. That object contains a member called items, which is an array, and each element in the array is either null or a child object. As you can see, it would be cumbersome to extract a single descendant as it would require getting a child handle, followed by another child handle, and so on. That is why the GET service supports a path.
...
Note |
---|
This service always returns a JSON Strings or values. If you want to get the JSON Entity Handle, you need to use GET instead. |
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 some values If SRP_JSON(ObjectHandle, "PARSE", SampleJSON) EQ "" then TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.items[1].id") TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.items[12].label") TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.items[3]") TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.testbool") TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.testint") TestValue = SRP_JSON(ObjectHandle, "GETVALUE", "menu.testreal") SRP_JSON(ObjectHandle, "RELEASE") end |