Q:What is JSON?
JSON is a text-based format for representing and exchanging structured data. It supports objects, arrays, strings, numbers, booleans, and null.
Q:What does JSON stand for?
JSON stands for JavaScript Object Notation.
Q:Is JSON a programming language?
No. JSON is a data format. Its syntax was derived from JavaScript object notation, but JSON itself is used independently of JavaScript.
Q:What are the JSON data types?
JSON supports objects, arrays, strings, numbers, booleans, and null.
Q:Does JSON use single or double quotes?
Standard JSON uses double quotes for strings and object property names. Single-quoted strings are not valid standard JSON.
Q:Can JSON contain comments?
Standard JSON does not support comments. Some JSON-based configuration formats add comment support, but those are extensions rather than standard JSON.
Q:Can JSON contain trailing commas?
No. Standard JSON does not allow a trailing comma after the last property or array element.
Q:What is the difference between JSON and a JavaScript object?
JSON is text with a defined syntax, while a JavaScript object is an in-memory runtime value. JSON.parse() converts JSON text into JavaScript data, and JSON.stringify() converts JavaScript data into JSON text.
Q:How do I format JSON?
Use a JSON formatter or parse and serialize the data with indentation. In JavaScript, JSON.stringify(JSON.parse(json), null, 2) is a common approach.
Q:How do I validate JSON?
Parse the JSON with a JSON parser to check syntax. Use JSON Schema or application-level validation when you also need to verify structure, data types, required fields, or business rules.
Q:What causes JSON parsing errors?
Common causes include missing commas, unmatched brackets, invalid quotes, unquoted property names, invalid escape sequences, trailing commas, and other syntax violations.
Q:Can valid JSON still fail an API request?
Yes. An API can reject syntactically valid JSON because required fields are missing, values have the wrong types, an allowed value is invalid, authentication is missing, or a business rule is violated.
Q:What is JSON Schema?
JSON Schema is a vocabulary for describing the expected structure and constraints of JSON data. It can define properties, types, required fields, array rules, and other constraints.
Q:What is JSON parsing?
JSON parsing converts JSON text into an in-memory data structure that a program can access and manipulate.
Q:What is JSON serialization?
JSON serialization converts an in-memory data structure into JSON text, commonly before sending it through an API or saving it to a file.
Q:Is JSON case-sensitive?
JSON syntax distinguishes uppercase and lowercase literal names such as true, false, and null. Property names are strings, so application code can also treat differently cased property names as different keys.
Q:Can JSON contain Unicode characters?
Yes. JSON text can represent Unicode characters. JSON also provides escape syntax for representing characters when an escaped representation is preferred.
Q:Can JSON represent dates?
JSON has no dedicated date type. Applications commonly represent dates as strings, often using an agreed format such as an ISO-style timestamp.
Q:Can JSON represent undefined?
No. undefined is a JavaScript value, not a JSON value. Applications generally omit such properties or represent the absence of a value with null when appropriate.
Q:Is JSON the same as YAML?
No. JSON and YAML are different data formats with different syntax and features, although JSON syntax is compatible with a subset of YAML.