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. Replies
    1. Instead of passing json keys to list map, how can I pass json keys Data to map and get this key Data to list string in spinner without these signs? Example: json =[{"key":""good":"number":9:}] in spinner
      Good
      9?
      I'm spinner

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

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

      Delete
  3. Nice tut

    How can receive json from Google blogger API

    Please help us

    ReplyDelete
  4. 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
  5. 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
  6. 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
  7. This comment has been removed by the author.

    ReplyDelete
  8. 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
  9. How can I create a search function on a json file, with objects?

    ReplyDelete
  10. how to resolve this part

    "content": "\u003cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003e\u003ca href=\"https://1.bp.blogspot.com/-szfVemeQeqk/XtdT7NnManI/AAAAAAAAAeI/kjBr5GnUa4sCGOO4P_EvjT7ZfgZvEY_8gCK4BGAsYHg/IMG_20200523_095258_4%257E2.jpg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border=\"0\" data-original-height=\"2775\" data-original-width=\"2899\" src=\"https://1.bp.blogspot.com/-szfVemeQeqk/XtdT7NnManI/AAAAAAAAAeI/kjBr5GnUa4sCGOO4P_EvjT7ZfgZvEY_8gCK4BGAsYHg/s320/IMG_20200523_095258_4%257E2.jpg\" width=\"320\" /\u003e\u003c/a\u003ethis is body\u003c/div\u003e",

    please help

    ReplyDelete
  11. PLEASE HELP ME IN SKETCHWARE
    please i want to read json response {"id": "XXX", "user":"stringuser"} from url so i display it in view text
    and save one of the json keys as string

    url example = "https://WWWW/yyyyyy?id=XXX"
    need to have the response and get the json keys the url every time changing the id XXX and do same thing according to list of ids XXX
    and the post request have headers
    'Accept': 'application/json'
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'

    ReplyDelete
  12. Pls help me
    How can I add image file in json in sketchware.

    ReplyDelete
  13. waw... very nice bro. thank thanks thanks.. muachh... you has been fix my problem

    ReplyDelete
  14. Your article is good to understand, are you interested in doors and windows? Our service is helpful to you.
    Modern aluminium doors in chennai
    Best Aluminium Windows in Chennai
    upvc ventilator window in Chennai

    ReplyDelete
  15. Before into JSON syntax and Masters Dissertation Writing Services, I would like to know whether I can use this syntax with Java or Python.

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware