Item:OSWf1df064239044b8fa3c968339fb93344: Difference between revisions

From OpenSemanticWorld
Item:OSWf1df064239044b8fa3c968339fb93344
(update from wiki-dev)
Tag: 2017 source edit
m (Protected "JSON Tutorial": Protected as read-only import via Page Exchange extension ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading])
 
(One intermediate revision by the same user not shown)
jsondata
Line 1: Line 1:
{
{
    "required_predecessor": [],
"type": [
    "optional_predecessor": [],
"Category:OSW494f660e6a714a1a9681c517bbb975da"
    "recommended_successor": [
],
        "Item:OSWf4a9514baed04859a4c6c374a7312f10",
"uuid": "f1df0642-3904-4b8f-a3c9-68339fb93344",
        "Item:OSW911488771ea449a6a34051f8213d7f2f"
"label": [
    ],
{
    "type": [
"text": "JSON Tutorial",
        "Category:OSW494f660e6a714a1a9681c517bbb975da"
"lang": "en"
    ],
}
    "uuid": "f1df0642-3904-4b8f-a3c9-68339fb93344",
],
    "name": "JsonTutorial",
"description": [
    "label": [
{
        {
"text": "Covers basics about JSON-Documents",
            "text": "JSON Tutorial",
"lang": "en"
            "lang": "en"
}
        }
],
    ],
"required_predecessor": [],
    "description": [
"optional_predecessor": [],
        {
"recommended_successor": [
            "text": "Covers basics about JSON-Documents",
"Item:OSWf4a9514baed04859a4c6c374a7312f10",
            "lang": "en"
"Item:OSW911488771ea449a6a34051f8213d7f2f"
        }
],
    ],
"name": "JsonTutorial",
    "image": "File:OSW2055124fe7b344148a1baad537bf8e35.png"
"image": "File:OSW2055124fe7b344148a1baad537bf8e35.png",
"part_of": [
"Item:OSWae8546dad40e487fa837db9c5ab07a5f"
]
}
}

Latest revision as of 05:08, 13 January 2026

JSON Tutorial ID: OSWf1df064239044b8fa3c968339fb93344 | UUID: f1df0642-3904-4b8f-a3c9-68339fb93344 | 📦: world.opensemantic.meta.docs.core
ID OSWf1df064239044b8fa3c968339fb93344
UUID f1df0642-3904-4b8f-a3c9-68339fb93344
Label JSON Tutorial
Machine compatible name JsonTutorial
Types/Categories Tutorial
OSW2055124fe7b344148a1baad537bf8e35.png
Statements (outgoing)
Statements (incoming)
Details

Description[edit source]

Covers basics about JSON-Documents

Item
Type(s)/Category(s) Tutorial
Tutorial
Prerequisites (required)
Prerequisites (optional)
Follow-up (recommended) JSON-SCHEMA Tutorial
JSON-LD Tutorial

View as slide show

JSON Documents: Basics[edit | edit source]

What is a JSON?

  • A JSON itself is a JSON object, marked by [1]
{}

JSON Documents: Key-Value-Pairs[edit | edit source]

  • A JSON object defines key(word):value pairs.
  • Keys are formatted as strings, marked by quotation marks ("").
{
    "key": "value"
}

JSON Documents: Data types[edit | edit source]

  • The key is always a string
  • The value can be a string, a number, a boolean or null
  • Additional data types are only possible by referencing them as external resources
{
    "key": "value",
    "string": "any string value",
    "number": 1.0,
    "bool": true,
    "empty": null,
    "image": "https://my.cloud/image-1.png"
}

JSON Documents: Subobjects[edit | edit source]

  • The value can also be a JSON document (object) itself
  • A nested object can have the same key-value pairs as the root document
  • There is no limit in the nesting depth
{
    "key": "value",
    "string": "any string value",
    "number": 1.0,
    "bool": true,
    "empty": null,
    "object": {
        "has": "it's own key-value-pairs"
    }
}

JSON Documents: Arrays[edit | edit source]

  • The value can also be an array (list)
  • An array can contain any element, including objects and nested arrays
{
    "key": "value",
    "string": "any string value",
    "number": 1.0,
    "bool": true,
    "empty": null,
    "object": {
        "has": "it's own key-value-pairs"
    },
    "array": [
        "a list", 
        {"of": "any"}, 
        ["item1", 1.0, true]
    ]
}

JSON Documents: Pointer[edit | edit source]

Pointer allow reference to

  • An object within the JSON document
{
    "firstname": "Susan",
    "surname": "Birch",
    "kids": ["Anne", "Tom"],
    "emergency_contact": {
        "$ref": "#/kids/0"
    }    
}

Syntax [2]:

# - the whole document = self-reference

#/kids - the value of the key "kids"

#/kids/0 - the first item within the array "kids"

JSON Documents: Reference[edit | edit source]

References allow reference to

  • An external JSON document
  • Combined with a pointer: An object within the external JSON document
{
    "firstname": "Susan",
    "surname": "Birch",
    "partner": {
        "$ref": "http://www.personaldata.com/walter.birch.json"
    },
    "partner_firstname": {
        "$ref": "http://www.personaldata.com/walter.birch.json#firstname"
    }
}

Specification: [3]

JSON Documents: Path[edit | edit source]

Paths allow query / filter values within a JSON document

{
  "store": {
    "book": [
      { "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ]
  }
}
  • $.store.book[*].price => [8.95, 22.99]
  • $.store.book[?(@.title == 'The Lord of the Rings')].price => 22.99

Specification: [4]

Conceptually also available as AWS S3 Select[5] and Postgres JSONB [6]

JSON vs. YAML[edit | edit source]

YAML version 1.2 is a superset of JSON with a simplified syntax

JSON (more machine-friendly)
{
  "store": {
    "book": [
      { "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ]
  }
}
YAML (more human-friendly)
# comments are allowed
store:
  book:
  - author: Nigel Rees
    title: Sayings of the Century
    price: 8.95
  - author: J. R. R. Tolkien
    title: The Lord of the Rings
    isbn: 0-395-19395-8 
    price: 22.99

JSON Documents: Next[edit | edit source]


📎 Select files (or drop them here)... 📷 Camera
    jsondata
    type
    "Category:OSW494f660e6a714a1a9681c517bbb975da"
    uuid"f1df0642-3904-4b8f-a3c9-68339fb93344"
    label
    text"JSON Tutorial"
    lang"en"
    description
    text"Covers basics about JSON-Documents"
    lang"en"
    required_predecessor
    Empty array
    optional_predecessor
    Empty array
    recommended_successor
    "Item:OSWf4a9514baed04859a4c6c374a7312f10"
    "Item:OSW911488771ea449a6a34051f8213d7f2f"
    name"JsonTutorial"
    image"File:OSW2055124fe7b344148a1baad537bf8e35.png"
    part_of
    "Item:OSWae8546dad40e487fa837db9c5ab07a5f"
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.