मुख्य सामग्री पर जाएँ
FreeOnlineTools Go
हिन्दी

संदर्भ

JSON सिंटैक्स संदर्भ

JSON सिंटैक्स (RFC 8259) का पूर्ण संदर्भ जिसमें डेटा प्रकार, व्याकरण नियम, उदाहरण और सामान्य त्रुटियाँ शामिल हैं।

Last updated: 2026-08-28

categorynamesyntaxdescription
TypeString"hello world"Unicode character sequence wrapped in double quotes. Supports escape sequences: \" \\ \/ \b \f \n \r \t \uXXXX
TypeNumber42, -3.14, 1e10, 2.5E-3IEEE 754 double-precision float. No leading zeros (except 0 itself), no NaN, no Infinity, no hexadecimal
TypeBooleantrue | falseLiteral lowercase keywords true or false (not quoted, not capitalized)
TypeNullnullLiteral lowercase keyword null representing absence of value (not quoted)
TypeObject{"key": value, ...}Unordered collection of key-value pairs. Keys must be unique strings. Empty object: {}
TypeArray[value, value, ...]Ordered sequence of values of any type. Empty array: []. Values can be mixed types
RuleDouble quotes only"key": "value"Strings and keys must use double quotes. Single quotes are invalid
RuleQuoted keys{"name": "Alice"}Object keys must be wrapped in double quotes (unlike JavaScript object literals)
RuleNo trailing comma{"a": 1, "b": 2}The last element in an object or array must not have a trailing comma
RuleRoot structure{...} or [...]Top-level value must be an object or array (per RFC 8259, any value is valid, but many parsers require object/array)
RuleNo commentsN/AJSON does not support // or /* */ comments (unlike JSON5 or JavaScript)
RuleEscape sequences"line1\nline2"Use backslash to escape: \" \\ \/ \b \f \n \r \t \uXXXX (4 hex digits)
RuleUnique keys{"a": 1, "b": 2}Object keys should be unique. Duplicate keys produce undefined behavior (last wins in most parsers)
RuleNumber format-?[0-9]+(.[0-9]+)?([eE][+-]?[0-9]+)?Optional minus, integer part, optional fraction, optional exponent. No leading zeros, no + sign, no hex
ExampleSimple object{"name": "Alice", "age": 30, "active": true}A person object with string, number, and boolean values
ExampleNested structure{"user": {"id": 1}, "tags": ["a", "b"]}Object containing nested object and array
ExampleArray of objects[{"id": 1}, {"id": 2}]Array containing multiple objects (common in API responses)
ExampleMixed array[1, "two", true, null, [5]]Array with mixed types: number, string, boolean, null, nested array
ExampleEmpty values{}, [], ""Empty object, empty array, and empty string are all valid JSON values
ErrorSingle quotes{'key': 'value'}INVALID: JSON requires double quotes for strings and keys
ErrorTrailing comma{"a": 1, "b": 2,}INVALID: Trailing comma after the last element is not allowed
ErrorUnquoted keys{name: "Alice"}INVALID: Object keys must be wrapped in double quotes
ErrorComments{/* comment */ "a": 1}INVALID: JSON does not support comments of any style
ErrorNaN / Infinity{"value": NaN}INVALID: NaN, Infinity, and -Infinity are not valid JSON numbers
ErrorLeading zeros{"value": 007}INVALID: Numbers cannot have leading zeros (use 7, not 007)
ErrorUndefined{"value": undefined}INVALID: undefined is not a JSON value (use null for absence)
ErrorHex numbers{"value": 0xFF}INVALID: Hexadecimal literals are not supported (use decimal 255)
ErrorMissing quotes{name: Alice}INVALID: Both keys and string values require double quotes

Related Tools