পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Saturday, January 21, 2017

JSON - Schema

JSON Schema is a specification for JSON based format for defining the structure of JSON data. It was written under IETF draft which expired in 2011. JSON Schema −

  • Describes your existing data format.
  • Clear, human- and machine-readable documentation.
  • Complete structural validation, useful for automated testing.
  • Complete structural validation, validating client-submitted data.

JSON Schema Validation Libraries

There are several validators currently available for different programming languages. Currently the most complete and compliant JSON Schema validator available is JSV.
Languages Libraries
C WJElement (LGPLv3)
Java json-schema-validator (LGPLv3)
.NET Json.NET (MIT)
ActionScript 3 Frigga (MIT)
Haskell aeson-schema (MIT)
Python Jsonschema
Ruby autoparse (ASL 2.0); ruby-jsonschema (MIT)
PHP php-json-schema (MIT). json-schema (Berkeley)
JavaScript Orderly (BSD); JSV; json-schema; Matic (MIT); Dojo; Persevere (modified BSD or AFL 2.0); schema.js.

JSON Schema Example

Given below is a basic JSON schema, which covers a classical product catalog description −
{
   "$schema": "http://json-schema.org/draft-04/schema#",
   "title": "Product",
   "description": "A product from Acme's catalog",
   "type": "object",
 
   "properties": {
 
      "id": {
         "description": "The unique identifier for a product",
         "type": "integer"
      },
  
      "name": {
         "description": "Name of the product",
         "type": "string"
      },
  
      "price": {
         "type": "number",
         "minimum": 0,
         "exclusiveMinimum": true
      }
   },
 
   "required": ["id", "name", "price"]
}
Let's the check various important keywords that can be used in this schema −
Keywords Description
$schema The $schema keyword states that this schema is written according to the draft v4 specification.
title You will use this to give a title to your schema.
description A little description of the schema.
type The type keyword defines the first constraint on our JSON data: it has to be a JSON Object.
properties Defines various keys and their value types, minimum and maximum values to be used in JSON file.
required This keeps a list of required properties.
minimum This is the constraint to be put on the value and represents minimum acceptable value.
exclusiveMinimum If "exclusiveMinimum" is present and has boolean value true, the instance is valid if it is strictly greater than the value of "minimum".
maximum This is the constraint to be put on the value and represents maximum acceptable value.
exclusiveMaximum If "exclusiveMaximum" is present and has boolean value true, the instance is valid if it is strictly lower than the value of "maximum".
multipleOf A numeric instance is valid against "multipleOf" if the result of the division of the instance by this keyword's value is an integer.
maxLength The length of a string instance is defined as the maximum number of its characters.
minLength The length of a string instance is defined as the minimum number of its characters.
pattern A string instance is considered valid if the regular expression matches the instance successfully.
You can check a http://json-schema.org for the complete list of keywords that can be used in defining a JSON schema. The above schema can be used to test the validity of the following JSON code −
[
   {
      "id": 2,
      "name": "An ice sculpture",
      "price": 12.50,
   },
 
   {
      "id": 3,
      "name": "A blue mouse",
      "price": 25.50,
   }
]

No comments:

Post a Comment