What are the data types supported by JSON?

  • Share this:

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is based on a subset of the JavaScript programming language. JSON supports the following data types:

  1. Number: JSON can represent integers, floating-point numbers, and numbers in scientific notation.
  2. String: JSON can represent characters, strings, and multi-line strings. Strings must be written in double quotes.
  3. Boolean: JSON can represent the values `true` and `false`.
  4. Null: JSON can represent the special value `null`, which indicates the absence of a value or a null reference.
  5. Object: JSON can represent collections of key-value pairs, where the keys are strings and the values can be any of the other JSON data types.
  6. Array: JSON can represent ordered lists of values, where the values can be any of the other JSON data types.

Here is an example of a JSON object that includes values of various data types:

  "name": "John Smith",
  "age": 30,
  "isEmployed": true,
  "favoriteColors": ["red", "blue"],
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY"

In this example, the data types of the values are string, number, boolean, array of strings, and object.

About author
I am a professional web developer. I love programming and coding, and reading books. I am the founder and CEO of StorialTech.