SIMPLE_JSON_QUICK

Zero-Configuration JSON for Beginners

v1.0.0 MIT

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

FeatureDescription
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

FeatureDescription
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

FeatureDescription
objectStart fluent object builder
from_pairs (pairs)Build object from key-value pairs

Validation

FeatureDescription
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 EiffelNeed JSON Schema validation
Simple config file parsingNeed JSON Patch/Pointer
Quick one-liner operationsProcessing large files
Building simple JSON responsesNeed custom serialization