Versions Compared

Key

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

...

IMPORTANT: Any JSON entity created by this service must be deallocated from memory when no longer needed using the RELEASE service. Forgetting to do this on occasion will not cause a fatal error since SRP Utilities will clean up all its memory when OpenInsight closes, but frequently failing to release entities causes memory to get used up, which can become a problem over long periods of time.

...

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
If SRP_JSON(ObjectHandle, "PARSE", SampleJSON) EQ "" then
   
   // Grab some values
   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")
   
   // Release the object because we're all done
   SRP_JSON(ObjectHandle, "RELEASE")

end

See Also

NEWRELEASE