HomeGuidesRecipesAPI
HomeGuidesAPILog In

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents.

πŸ“˜

Relevant Links

https://json-schema.org/learn/getting-started-step-by-step


Connector Set-Up

A JSON schema defines the Data Object filter and display fields relative to the data file. Create and upload the JSON data and schema files directly to use as a data source in SmartIQ. Alternatively you can define the location of the file using connection attributes.

πŸ‘

How to create a JSON Schema?

The easiest way to generate a JSON schema is taking a sample JSON response from our API and create a schema based on it.

There are also a good number of online free tools and Integrated Development Environment (IDE) add-ons. https://json-schema.org/learn/getting-started-step-by-step

Example Data and Schema Files

{
    "person":[
        {
            "name": "John Doe",
            "dateOfBirth": "29/06/1985",
            "eMail": "[email protected]",
            "assets": [
                {
                    "type": "Car",
                    "value": "7000",
                    "description": "Jeep Grand Cherokee"
                },
                {
                    "type": "Car",
                    "value": "15000",
                    "description": "Hyundai - i30"
                },
                {
                    "type": "House",
                    "value": "400000",
                    "description": "Sydney - Australia"
                }
            ]
        },
        {
            "name": "Steven Smith",
            "dateOfBirth": "15/06/1950",
            "eMail": "[email protected]",
            "assets": [
                {
                    "type": "Apartment",
                    "value": "500000",
                    "description": "By the lake - Melbourne - Australia"
                }
            ]
        },
        {
            "name": "Rose Mathews",
            "dateOfBirth": "15/04/1931",
            "eMail": "[email protected]",
            "assets": [
                {
                    "type": "Apartment",
                    "value": "1000000",
                    "description": "Brisbane"
                },
                {
                    "type": "Apartment",
                    "value": "650000",
                    "description": "Canberra"
                },
                {
                    "type": "House",
                    "value": "720000",
                    "description": "Perth"
                },
                {
                    "type": "Car",
                    "value": "34000",
                    "description": "Audi - t3"
                }
            ]
        }
    ]
}
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {},
    "id": "SmartIQ",
    "properties": {
        "person": {
            "id": "/properties/person",
            "items": {
                "id": "/properties/person/items",
                "properties": {
                    "assets": {
                        "id": "/properties/person/items/properties/assets",
                        "items": {
                            "id": "/properties/person/items/properties/assets/items",
                            "properties": {
                                "description": {
                                    "id": "/properties/person/items/properties/assets/items/properties/description",
                                    "type": "string"
                                },
                                "type": {
                                    "id": "/properties/person/items/properties/assets/items/properties/type",
                                    "type": "string"
                                },
                                "value": {
                                    "id": "/properties/person/items/properties/assets/items/properties/value",
                                    "type": "string"
                                }
                            },
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "dateOfBirth": {
                        "id": "/properties/person/items/properties/dateOfBirth",
                        "type": "string"
                    },
                    "eMail": {
                        "id": "/properties/person/items/properties/eMail",
                        "type": "string"
                    },
                    "name": {
                        "id": "/properties/person/items/properties/name",
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "type": "array"
        }
    },
    "type": "object"
}

Connection Attributes

The schema can be defined by setting the connection attribute schema=http://[jsonserverurl]/data.schema.json;json=http://[jsonserverurl]/data.json to the JSON schema to use for the connection.

Data Objects

The schema file defines the Filter Fields for the file data object.