Json - Json Schema
JSON (JavaScript Object Notation) data is an easy-to-read and machine-processable data format consisting of key-value pairs.
• ad: string
• yas: integer
• evli_mi: boolean
• hobiler: array
• adres:object
{
"ad": "Ahmet",
"yas": 30,
"evli_mi": true,
"hobiler": ["kitap okumak", "yuzme", "fotografcilik"],
"adres": {
"sehir": "İstanbul",
"posta_kodu": "34000"
}
}
Json Schema
JSON Schema is a standard used to define the structure, content, and rules of JSON data. It provides a template for checking whether JSON data is in the correct format and conforms to the desired rules.
Json Schema Example
• type: Expected data type (e.g. "object")
• properties: Keys that should be in this object and their types
• required :List of required fields
• minimum: Lower limit for number (age cannot be less than 0)
• additionalProperties: Specifies that there should be no other fields outside this object (false)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"ad": {
"type": "string"
},
"yas": {
"type": "integer",
"minimum": 0
}
},
"required": ["ad", "yas"],
"additionalProperties": false
}
Result
JSON Schema, JSON verisini doğrulamak ve belgelemek için kullanılan standart bir şemadır.