JavaScript

JavaScript is a high-level, interpreted programming language that is widely used for web development. Initially designed as a client-side scripting language, it runs directly in web browsers, enabling dynamic and interactive user experiences. JavaScript can now be used for server-side development as well.

JSON Data Types

15 April 2025 | Category:

In JSON (JavaScript Object Notation), data is represented using a small set of well-defined data types. These types are used to hold different kinds of values like text, numbers, lists, or even other structured data.

JSON supports six basic data types, all of which are easy to understand and use.


✅ List of JSON Data Types

Data TypeDescriptionExample
StringA sequence of characters"name": "Alice"
NumberNumeric values (integer or float)"age": 25
BooleanLogical value: true or false"isStudent": false
ArrayA list of values in order"skills": ["HTML", "CSS"]
ObjectA collection of key/value pairs"address": { "city": "Delhi" }
NullRepresents an empty or unknown value"spouse": null

🔎 JSON Data Type Examples

1. String

A string must be wrapped in double quotes.

{
  "firstName": "John"
}

2. Number

No quotes are used. Can be integer or floating-point.

{
  "age": 30,
  "height": 5.9
}

3. Boolean

Must be lowercase: true or false.

{
  "isActive": true
}

4. Array

A list of values enclosed in square brackets []. It can contain multiple data types.

{
  "colors": ["red", "green", "blue"],
  "marks": [85, 90, 78]
}

5. Object

Enclosed in curly braces {}, with key/value pairs inside.

{
  "person": {
    "name": "Rahul",
    "age": 22
  }
}

6. Null

Used to represent “no value”.

{
  "middleName": null
}

🧠 Important Notes

  • Keys must always be strings.
  • You can nest arrays and objects to create complex data structures.
  • JSON does not support functions, dates (as native types), or comments.

🎯 Summary

  • JSON supports 6 main data types: String, Number, Boolean, Array, Object, and Null.
  • Each type has a specific structure and usage.
  • JSON is ideal for representing structured data for APIs and web communication.