HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

JSON Data Types

In JSON, values must be one of the following six data types. Any other data (like functions, variables, or dates) will make the JSON invalid.


Supported Data Types

Explore the valid types and how they are written in JSON syntax:

1. String

Must be in double quotes.

"name": "Hridoy"
2. Number

Integer or decimal.

"age": 25
3. Object

Nested key-value pairs.

{"city": "Dhaka"}
4. Array

A list of JSON values.

["HTML", "JS"]
5. Boolean

True or False.

"active": true
6. Null

Empty value.

"middle": null

Detailed Breakdown

JSON Strings

Strings in JSON must be wrapped in double quotes " ". Single quotes are not allowed.

{"name": "RedoHub"}

JSON Numbers

Numbers in JSON must be an integer or a floating point. They should not be wrapped in quotes.

{"price": 19.99, "count": 100}

JSON Objects

Values in JSON can be other JSON objects. This allows for deep nesting.

{
  "user": {
    "id": 1,
    "login": "admin"
  }
}

JSON Arrays

Values in JSON can be arrays. An array in JSON can contain strings, numbers, objects, or even other arrays.

{"tags": ["Web", "Dev", "Learning"]}
Tip: While you cannot store a Date object in JSON, you should store it as an ISO string: "2026-04-18".

What is NOT Allowed?

Standard JSON does not support:

  • Functions: You cannot pass executable code.
  • Undefined: Use null instead.
  • Dates: Must be converted to strings.

Key Points to Remember

  • There are exactly 6 valid data types in JSON.
  • Strings must always use double quotes.
  • Numbers and Booleans should not use quotes.
  • JSON allows for **complex nesting** of objects and arrays.
  • Functions and Dates are invalid in JSON.