JSON syntax


JSON syntax rules

  • Data is in name/value pairs

  • "My name" : "Sanjeev"

  • Data is separated by commas

  • {
    "name" : "Sanjeev",
    "age" : "29",
    "registration number" : "1628634"
    }

  • Curly braces hold objects

  • {
    "name" : "Sanjeev",
    "age" : "29",
    "registration number" : "1628634"
    }

  • Square brackets hold arrays

  • [
    {
    "name" : "Sanjeev",
    "age" : "29"
    },
    {
    "name" : "Ranju",
    "age" : "25"
    },
    {
    "name" : "Anand",
    "age" : "16"
    },
    {
    "name" : "Richa",
    "age" : "20"
    }
    ]
  • A name/value pair consists of 
    a field name or key (in double quotes),
    followed by a colon,
    followed by a value.

    { "name" : "Sanjeev" }

Types of Values in JSON

In JSON, values must be one of 
the following data types:

  • a string (Strings in JSON must be written in double quotes)
  • {
    "age" : "27" 
    }

  • a number
  • {
    "age" : 27 
    }

  • an object (JSON object)
  • {
    "age" : { "original" : "27",
    "fake" : "26" } 

    }

  • an array
  • {
    "age" : [ {"original" : "27", "fake" : "26"},
    {"original" : "20", "fake" : "24"},
    {"original" : "88", "fake" : "78"}
    ] 

    }

  • a boolean
  • {
    "age" : true 
    }

  • null
  • {
    "age" : null 
    }

JSON Files
  • The file type for JSON files is ".json "
  • The MIME type for JSON text is
    "application/json"

Use in Sketchware
  • Json Object can be converted to Map Variable using the block Json... to Map


  • Json Array can be converted to Map List using the block Json... to ListMap

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key