Ambrosius Topor

Notiz — 2024-01-03

JSON — An Appraisal

JSON is such an useful format.
Concise and simple, still allowing one to create complex data structures and tooling around it.

While I have been using JSON-ML a long time ago, there are quite a lot of other specifications that standardize development and help you moving forward faster.

JSON-ML

Lets you describe Markdown in JSON.

["h1", { "class": "title is-4" }, "An Example Header"]

JSON Schema

Used to describe JSON objects/documents, enabling consistency, validation and interoperability.

Example (simplistic) schema definition:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://example.com/dog.schema.json",
    "title": "Dog",
    "description": "A schema of a dog",
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        },
        "age": {
            "type": "integer"
        }
    }
}

This would describe a structure like this:

{
    "name": "Snoopy",
    "age": 7
}

JSON-RPC, OpenRPC

JSON-RPC is a light-weight, transport agnostic remote procedure call protocol.
To describe JSON-RPC methods, OpenRPC can be used.

A request looks like this:

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "query_page",
    "params": {
        "path": "/contact"
    }
}

JSON Patch, JSON Pointer

Used to describe changes in a JSON document. Some of the operations are "add", "replace" and "remove".
Paths are addressed by using JSON Pointer.

[
    { "op": "replace", "path": "/foo", "value": "bar" }
]

References

Comments

There are no comments yet.

Thanks for your contribution!
Your comment will be visible once it has been approved.

An error occured—please try again.

Add Comment