Easy JSON examples

Suragch
2 min readFeb 8, 2019

I was trying to find a link to some simple examples of how to format JSON, but I couldn’t find what I was looking for. So I am making my own examples below. They are based on the documentation. You can format and validate JSON here.

Object

  • Objects are surrounded with { } curly braces.
  • Elements in the object are key-value pairs (name-value pairs).
  • Keys must be quoted with " double quotes.
  • Keys and values are separated by a : colon.
  • Multiple key-value pairs are separated by , commas.
  • Key-value pairs are unordered.
  • White space doesn’t matter.
{
"name" : "Mary",
"age" : 30
}

Array

  • Arrays are surrounded with [ ] square brackets.
  • Elements of the array are values.
  • Multiple values are separated by , commas.
  • Array values are ordered.
{
"animals" : [
"horse",
"cow",
"camel",
"sheep",
"goat"
]
}

In the example above, "animals" is a key (name) and the [...] array is a value.

Value

  • Values can be strings, numbers, objects, arrays, boolean true or false, or null.
{
"myString" : "Hello world",
"myNumber" : 42,

--

--

Suragch
Suragch

Written by Suragch

Flutter and Dart developer. Twitter: @suragch1, Email: suragch@suragch.dev

No responses yet