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:
- Number: JSON can represent integers, floating-point numbers, and numbers in scientific notation.
- String: JSON can represent characters, strings, and multi-line strings. Strings must be written in double quotes.
- Boolean: JSON can represent the values `true` and `false`.
- Null: JSON can represent the special value `null`, which indicates the absence of a value or a null reference.
- 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.
- 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.
Comments (0)