JSON Syntax

You are Here:

String and Number

In the following example, we will learn how to use string value and number value in JSON.

Note: name is in string and age is in number.

Example

HTML Editor
[ { "name": "Mike", "age": 36 }, { "name": "Alex", "age": 30 } ]

Array

In the following example, we will learn how to use array value in JSON.

Note: friends is in array.

Example

HTML Editor
[ { "name": "Mike", "age": 36, "friends": ["John", "Antony"] }, { "name": "Alex", "age": 30, "friends": ["Jade", "Jasmine"] } ]

Object

In the following example, we will learn how to use object value in JSON.

Note: id is in object.

Example

HTML Editor
[ { "name": "Mike", "age": 36, "id": { "eyes": "brown", "hair": "blonde" } }, { "name": "Alex", "age": 30, "id": { "eyes": "blue", "hair": "brunette" } } ]

Array within Object

In the following example, we will learn how to use array within object in JSON.

Note: hair is in array and id is in object. So, array within object.

Example

HTML Editor
[ { "name": "Mike", "age": 36, "id": { "eyes": "brown", "hair": ["blonde", "golden"] } }, { "name": "Alex", "age": 30, "id": { "eyes": "blue", "hair": ["brunette", "brown"] } } ]

Object within Array

In the following example, we will learn how to use object within array in JSON.

Note: jade and antony are in objects and friends is in array. So, object within array.

Example

HTML Editor
[ { "name": "Mike", "age": 36, "friends": [{ "jade": { "gender": "female", "age": 25 }, "antony": { "gender": "male", "age": 35 } }] } ]

Reminder

Hi Developers, we almost covered 100% of JSON Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JSON.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author