Parse Strings And Bytes
Use /ork/cl_json=>parse to get the parser singleton, then choose string or bytes depending on the input source.
Lazy parsing is opt-in. Pass parser = /ork/cl_json_parser=>lazy to defer nested parsing until you navigate members or items, or until serialization needs the complete tree.
DATA(root) = /ork/cl_json=>parse->string(
`{ "items": [1, 2, 3], "name": "demo" }`
).
DATA(root_from_bytes) = /ork/cl_json=>parse->bytes(
json = json_xstring
).
Cast Nodes
The parser returns /ork/if_json_node. Cast to the shape you expect before reading members or array items.
DATA(object) = root->as_object( ).
DATA(items) = object->get( `items` )->as_array( ).
Read Members And Items
Object and array nodes expose typed access methods. Use the node interfaces when you need to defer the concrete type decision.
DATA(name) = object->get( `name` )->as_string( )->get( ).
DATA(first_item) = items->get( 1 )->as_number( )->get_int4( ).
Build And Serialize
Create node objects through the JSON facade, add members or items, then serialize with to_string.
DATA(factory) = /ork/cl_json=>new.
DATA(result) = factory->object(
)->set( name = `status` node = factory->string( `ok` )
)->set( name = `count` node = factory->number( 3 )
)->to_string( ).
Use /ork/cl_json_formatter when output formatting needs a dedicated policy.
Lazy Error Handling
Use /ork/cl_json_parser=>lazy when you want parsing errors to surface only when the invalid node is accessed.
DATA(root) = /ork/cl_json=>parse->string( json = `{ "lazy": error }`
parser = /ork/cl_json_parser=>lazy ).
TRY.
root->as_object( )->get( `lazy` ).
CATCH /ork/cx_exception INTO DATA(error) ##NEEDED.
ENDTRY.