SIMPLE_JSON
Main facade class for JSON operations. The primary entry point for the library.
Parsing
| Feature | Signature | Description |
|---|---|---|
parse |
(a_json_text: STRING_32): detachable SIMPLE_JSON_VALUE |
Parse JSON string. Returns Void on error; check last_errors. |
parse_file |
(a_file_path: STRING_32): detachable SIMPLE_JSON_VALUE |
Parse JSON from file. Returns Void on error. |
is_valid_json |
(a_json_text: STRING_32): BOOLEAN |
Check if text is valid JSON without creating value. |
Error Tracking
| Feature | Signature | Description |
|---|---|---|
has_errors |
: BOOLEAN |
Were there errors during last parse? |
last_errors |
: ARRAYED_LIST [SIMPLE_JSON_ERROR] |
List of errors from last parse. |
error_count |
: INTEGER |
Number of errors. |
first_error |
: detachable SIMPLE_JSON_ERROR |
First error, if any. |
errors_as_string |
: STRING_32 |
All errors as single string. |
detailed_errors |
: STRING_32 |
All errors with line/column context. |
clear_errors |
|
Clear error list. |
Building
| Feature | Signature | Description |
|---|---|---|
new_object |
: SIMPLE_JSON_OBJECT |
Create empty JSON object builder. |
new_array |
: SIMPLE_JSON_ARRAY |
Create empty JSON array builder. |
string_value |
(a_string: STRING_32): SIMPLE_JSON_VALUE |
Create JSON string value. |
number_value |
(a_number: DOUBLE): SIMPLE_JSON_VALUE |
Create JSON number value. |
integer_value |
(a_integer: INTEGER_64): SIMPLE_JSON_VALUE |
Create JSON integer value. |
boolean_value |
(a_boolean: BOOLEAN): SIMPLE_JSON_VALUE |
Create JSON boolean value. |
null_value |
: SIMPLE_JSON_VALUE |
Create JSON null value. |
JSONPath Queries
| Feature | Signature | Description |
|---|---|---|
query_string |
(a_value: SIMPLE_JSON_VALUE; a_path: STRING_32): detachable STRING_32 |
Query single string value. Example: "$.person.name" |
query_integer |
(a_value: SIMPLE_JSON_VALUE; a_path: STRING_32): INTEGER_64 |
Query single integer. Returns 0 if not found. |
query_strings |
(a_value: SIMPLE_JSON_VALUE; a_path: STRING_32): ARRAYED_LIST [STRING_32] |
Query multiple strings with wildcards. Example: "$.users[*].name" |
query_integers |
(a_value: SIMPLE_JSON_VALUE; a_path: STRING_32): ARRAYED_LIST [INTEGER_64] |
Query multiple integers with wildcards. |
JSON Patch
| Feature | Signature | Description |
|---|---|---|
create_patch |
: SIMPLE_JSON_PATCH |
Create new empty patch. |
parse_patch |
(a_patch_json: STRING_32): detachable SIMPLE_JSON_PATCH |
Parse patch from JSON array string. |
apply_patch |
(a_document: SIMPLE_JSON_VALUE; a_patch_json: STRING_32): SIMPLE_JSON_PATCH_RESULT |
Parse and apply patch in one step. |
SIMPLE_JSON_VALUE
Wrapper around JSON values providing convenient typed access.
Type Checking
| Feature | Signature | Description |
|---|---|---|
is_string |
: BOOLEAN |
Is this a string value? |
is_number |
: BOOLEAN |
Is this a number value? |
is_integer |
: BOOLEAN |
Is this an integer value? |
is_boolean |
: BOOLEAN |
Is this a boolean value? |
is_null |
: BOOLEAN |
Is this a null value? |
is_object |
: BOOLEAN |
Is this an object value? |
is_array |
: BOOLEAN |
Is this an array value? |
Value Access
| Feature | Signature | Precondition |
|---|---|---|
as_string_32 |
: STRING_32 |
is_string |
as_number |
: DOUBLE |
is_number |
as_integer |
: INTEGER_64 |
is_integer |
as_boolean |
: BOOLEAN |
is_boolean |
as_object |
: SIMPLE_JSON_OBJECT |
is_object |
as_array |
: SIMPLE_JSON_ARRAY |
is_array |
Output
| Feature | Signature | Description |
|---|---|---|
to_json |
: STRING_32 |
Compact JSON string. |
to_pretty_json |
: STRING_32 |
Pretty-printed JSON with indentation. |
SIMPLE_JSON_OBJECT
JSON object with fluent builder API.
Creation
| Feature | Signature | Description |
|---|---|---|
make |
|
Create empty object. |
make_from_value |
(a_value: SIMPLE_JSON_VALUE) |
Create from existing value. |
Builder (returns LIKE CURRENT for chaining)
| Feature | Signature | Description |
|---|---|---|
put_string |
(a_key, a_value: STRING_32): like Current |
Add string property. |
put_integer |
(a_key: STRING_32; a_value: INTEGER_64): like Current |
Add integer property. |
put_number |
(a_key: STRING_32; a_value: DOUBLE): like Current |
Add number property. |
put_boolean |
(a_key: STRING_32; a_value: BOOLEAN): like Current |
Add boolean property. |
put_null |
(a_key: STRING_32): like Current |
Add null property. |
put_object |
(a_key: STRING_32; a_obj: SIMPLE_JSON_OBJECT): like Current |
Add nested object. |
put_array |
(a_key: STRING_32; a_arr: SIMPLE_JSON_ARRAY): like Current |
Add nested array. |
put_value |
(a_key: STRING_32; a_val: SIMPLE_JSON_VALUE): like Current |
Add any value. |
Access
| Feature | Signature | Description |
|---|---|---|
has |
(a_key: STRING_32): BOOLEAN |
Does key exist? |
item |
(a_key: STRING_32): detachable SIMPLE_JSON_VALUE |
Get value by key. |
string_item |
(a_key: STRING_32): detachable STRING_32 |
Get string value by key. |
integer_item |
(a_key: STRING_32): INTEGER_64 |
Get integer (0 if missing/wrong type). |
number_item |
(a_key: STRING_32): DOUBLE |
Get number (0.0 if missing/wrong type). |
boolean_item |
(a_key: STRING_32): BOOLEAN |
Get boolean (False if missing/wrong type). |
object_item |
(a_key: STRING_32): detachable SIMPLE_JSON_OBJECT |
Get nested object. |
array_item |
(a_key: STRING_32): detachable SIMPLE_JSON_ARRAY |
Get nested array. |
keys |
: ARRAYED_LIST [STRING_32] |
All property keys. |
count |
: INTEGER |
Number of properties. |
SIMPLE_JSON_ARRAY
JSON array with fluent builder API.
Builder (returns LIKE CURRENT for chaining)
| Feature | Signature | Description |
|---|---|---|
add_string |
(a_value: STRING_32): like Current |
Append string. |
add_integer |
(a_value: INTEGER_64): like Current |
Append integer. |
add_number |
(a_value: DOUBLE): like Current |
Append number. |
add_boolean |
(a_value: BOOLEAN): like Current |
Append boolean. |
add_null |
: like Current |
Append null. |
add_object |
(a_obj: SIMPLE_JSON_OBJECT): like Current |
Append object. |
add_array |
(a_arr: SIMPLE_JSON_ARRAY): like Current |
Append array. |
add_value |
(a_val: SIMPLE_JSON_VALUE): like Current |
Append any value. |
Access
| Feature | Signature | Description |
|---|---|---|
count |
: INTEGER |
Number of elements. |
valid_index |
(i: INTEGER): BOOLEAN |
Is index valid? (1-based) |
item |
(i: INTEGER): SIMPLE_JSON_VALUE |
Element at index (1-based). |
is_empty |
: BOOLEAN |
Is array empty? |
SIMPLE_JSON_POINTER
JSON Pointer (RFC 6901) navigation.
| Feature | Signature | Description |
|---|---|---|
parse_path |
(a_path: STRING_32): BOOLEAN |
Parse pointer path like "/users/0/name". |
value_at |
(a_root: SIMPLE_JSON_VALUE): detachable SIMPLE_JSON_VALUE |
Navigate to value at this pointer. |
segments |
: ARRAYED_LIST [STRING_32] |
Path segments after parsing. |
last_segment |
: STRING_32 |
Final segment (property name or index). |
SIMPLE_JSON_SCHEMA_VALIDATOR
JSON Schema validation (Draft 7).
| Feature | Signature | Description |
|---|---|---|
make |
|
Create validator. |
validate |
(a_instance: SIMPLE_JSON_VALUE; a_schema: SIMPLE_JSON_SCHEMA): SIMPLE_JSON_SCHEMA_VALIDATION_RESULT |
Validate instance against schema. |
SIMPLE_JSON_SCHEMA
| Feature | Signature | Description |
|---|---|---|
make_from_string |
(a_schema_json: STRING_32) |
Create schema from JSON string. |
make_from_value |
(a_value: SIMPLE_JSON_VALUE) |
Create schema from parsed JSON. |
SIMPLE_JSON_SCHEMA_VALIDATION_RESULT
| Feature | Signature | Description |
|---|---|---|
is_valid |
: BOOLEAN |
Did validation pass? |
errors |
: ARRAY [SIMPLE_JSON_SCHEMA_VALIDATION_ERROR] |
Validation errors. |
SIMPLE_JSON_PATCH
JSON Patch (RFC 6902) operations.
Adding Operations
| Feature | Signature | Description |
|---|---|---|
add_add |
(a_path: STRING_32; a_value: SIMPLE_JSON_VALUE) |
Add value at path. |
add_remove |
(a_path: STRING_32) |
Remove value at path. |
add_replace |
(a_path: STRING_32; a_value: SIMPLE_JSON_VALUE) |
Replace value at path. |
add_move |
(a_from, a_path: STRING_32) |
Move value from one path to another. |
add_copy |
(a_from, a_path: STRING_32) |
Copy value from one path to another. |
add_test |
(a_path: STRING_32; a_value: SIMPLE_JSON_VALUE) |
Test value at path equals expected. |
Applying
| Feature | Signature | Description |
|---|---|---|
apply |
(a_document: SIMPLE_JSON_VALUE): SIMPLE_JSON_PATCH_RESULT |
Apply patch to document. |
to_json |
: STRING_32 |
Serialize patch to JSON. |
SIMPLE_JSON_PATCH_RESULT
| Feature | Signature | Description |
|---|---|---|
is_success |
: BOOLEAN |
Did patch succeed? |
result_document |
: SIMPLE_JSON_VALUE |
Patched document (if success). |
error_message |
: STRING_32 |
Error message (if failure). |
SIMPLE_JSON_MERGE_PATCH
JSON Merge Patch (RFC 7386).
| Feature | Signature | Description |
|---|---|---|
apply |
(a_target, a_patch: SIMPLE_JSON_VALUE): SIMPLE_JSON_MERGE_PATCH_RESULT |
Apply merge patch to target. |
SIMPLE_JSON_STREAM
Streaming JSON parser for large files.
| Feature | Signature | Description |
|---|---|---|
make_from_string |
(a_json: STRING_32) |
Create stream from string. |
make_from_file |
(a_path: STRING_32) |
Create stream from file. |
new_cursor |
: SIMPLE_JSON_STREAM_CURSOR |
Get cursor for iteration. |
SIMPLE_JSON_ERROR
Parse error with position information.
| Feature | Signature | Description |
|---|---|---|
message |
: STRING_32 |
Error message. |
line |
: INTEGER |
Line number (1-based). |
column |
: INTEGER |
Column number (1-based). |
position |
: INTEGER |
Character position in source. |
to_string_with_position |
: STRING_32 |
Error with line:column prefix. |
to_detailed_string |
: STRING_32 |
Error with source context. |
JSON Type Constants
From SIMPLE_JSON_CONSTANTS:
| Constant | Value |
|---|---|
Json_type_string |
"string" |
Json_type_number |
"number" |
Json_type_integer |
"integer" |
Json_type_boolean |
"boolean" |
Json_type_null |
"null" |
Json_type_object |
"object" |
Json_type_array |
"array" |