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


Comments

  1. help ho decode this json:
    {"response":[{"uid":23euE7002wefTFtud5e6yuyt3476ruj86,"name":"Lindsey","age":23}]}

    ReplyDelete
    Replies
    1. [
      {
      "uid":"23euE7002wefTFtud5e6yuyt3476ruj86",
      "name":"Lindsey",
      "age":"23"
      }
      ]

      Delete
  2. Nice tut

    How can receive json from Google blogger API

    Please help us

    ReplyDelete
  3. In case I would like an external editor to prepare the json file, where would I find it? Is it accessible using file explorer?

    ReplyDelete
  4. Thank you! You are amazingly generous with your knowledge. I can only imagine what a great thing Sketchware would be if you were the developer instead of the irresponsible people who created it.

    This information is so important but I had no idea what it was at all until I saw this post.

    Again, thank you very much!

    ReplyDelete
  5. Please,am actually working on software which i'm using sketchware to develop. so , the part of the logic is I'm to have a listMap you know dat would contains set of objects with their different variables. So, i want to know how i can be adding another object to the listMap in such a way that the new object would target a particular existing object of that listMap and making its datas to replace all d similar keys in dat existing object......

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. How can I decode the posts object:

    {
    "kind": "blogger#blog",
    "id": "2405240931534618827",
    "name": "Saifiyo Diary",
    "description": "",
    "published": "2019-07-21T11:40:09+06:00",
    "updated": "2019-08-02T17:18:14+06:00",
    "url": "http://saifiyo.blogspot.com/",
    "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2405240931534618827",
    "posts": {
    "totalItems": 10,
    "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2405240931534618827/posts"
    },
    "pages": {
    "totalItems": 0,
    "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2405240931534618827/pages"
    },
    "locale": {
    "language": "en",
    "country": "",
    "variant": ""
    }
    }

    ReplyDelete
    Replies
    1. It is a json object which contains some keys whose values are Strings and some keys whose values are json objects.

      This video will help you https://youtu.be/z2BCzl-RR7o

      Delete
    2. I followed your video. But it showing errors.

      Delete
    3. Can you give me the code to decode the posts object?

      Delete
  8. How can I create a search function on a json file, with objects?

    ReplyDelete

Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Create Music Player app in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity