Overview
SIMPLE_JSON_QUICK provides the simplest possible JSON operations for beginners. One-liner parse, query, and build operations with sensible defaults.
For full control, use SIMPLE_JSON directly.
Quick Start
local
json: SIMPLE_JSON_QUICK
name: detachable STRING
do
create json.make
-- Parse and query in one call
name := json.get_string (json_string, "$.users[0].name")
-- Parse to object
if attached json.parse_object (json_string) as obj then
name := json.string_at (obj, "user.name")
end
-- Build JSON fluently
print (json.object.put ("name", "Alice").put ("age", 30).to_json)
-- {"name":"Alice","age":30}
-- Quick object from pairs
print (json.from_pairs (<<["city", "Paris"], ["country", "France"]>>))
-- Validation
if json.is_valid (some_string) then ...
if json.is_object (some_string) then ...
end
API Reference
Parsing
| Feature | Description |
|---|---|
parse (json) | Parse JSON string to value |
parse_object (json) | Parse JSON string to object |
parse_array (json) | Parse JSON string to array |
parse_file (path) | Parse JSON file |
Querying
| Feature | Description |
|---|---|
get_string (json, path) | Get string at JSONPath |
get_integer (json, path) | Get integer at JSONPath |
get_real (json, path) | Get real at JSONPath |
get_boolean (json, path) | Get boolean at JSONPath |
string_at (obj, dotpath) | Get string via dot-path |
integer_at (obj, dotpath) | Get integer via dot-path |
Building
| Feature | Description |
|---|---|
object | Start fluent object builder |
from_pairs (pairs) | Build object from key-value pairs |
Validation
| Feature | Description |
|---|---|
is_valid (json) | Is string valid JSON? |
is_object (json) | Is string a JSON object? |
is_array (json) | Is string a JSON array? |
When to Use QUICK vs Standard API
| Use QUICK when... | Use Standard API when... |
|---|---|
| Learning JSON in Eiffel | Need JSON Schema validation |
| Simple config file parsing | Need JSON Patch/Pointer |
| Quick one-liner operations | Processing large files |
| Building simple JSON responses | Need custom serialization |