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

TextInputLayout in Sketchware

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

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation