Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Sharique55/f3e219c0783f61492ec4557c54478792 to your computer and use it in GitHub Desktop.

Select an option

Save Sharique55/f3e219c0783f61492ec4557c54478792 to your computer and use it in GitHub Desktop.
πŸš€ The Ultimate JSON Cheatsheet – Everything You Need to Know About JSON

πŸš€ The Ultimate JSON Cheatsheet – Everything You Need to Know About JSON

πŸ’‘ A complete JSON reference in table format: structure, data types, syntax rules, validation, and real-world applications.


Category Subcategory Description Example
Basics JSON Definition Lightweight format for data-interchange, easy to read and write. { "key": "value" }
Structure Built on key-value pairs (objects) and ordered lists (arrays). { "name": "John", "age": 30 }
MIME Type MIME type for JSON is application/json. -
Data Types String Text enclosed in double quotes. "name": "John"
Number Can be integer or floating-point. "age": 30 or "weight": 70.5
Boolean Supports true and false. "isStudent": true
Null Represents absence of value. "middleName": null
Object Key-value collection, wrapped in {}. { "name": "John", "age": 30 }
Array Ordered list of values inside []. "hobbies": ["reading", "coding"]
Syntax Rules Double Quotes Keys and string values must use double quotes. "name": "John"
Key-Value Pair Separator Colon : separates keys from values. "age": 30
Comma Separation Items separated with commas. { "name": "John", "age": 30 }
No Trailing Comma Last item must not end with a comma. βœ… Correct: { "key": "val" } ❌ Incorrect: { "key": "val", }
White Spaces Whitespace is allowed and ignored. { "name" : "John" , "age" : 30 }
Advanced Structures Nested Objects JSON objects inside other objects. { "user": { "name": "John" } }
Nested Arrays Arrays within arrays. "matrix": [[1, 2], [3, 4]]
Arrays of Objects Array holding multiple object entries. [{"id": 1}, {"id": 2}]
Mixed Types in Arrays JSON array can mix data types. [1, "text", true, null]
Encoding Unicode JSON supports UTF-8 and Unicode. "symbol": "\u03C0"
Operations Parsing Convert JSON string to native object. JSON.parse('{"a":1}')
Stringifying Convert object to JSON string. JSON.stringify({a:1})
Accessing Data Use dot/bracket notation. obj.name or obj["name"]
Modifying Data Reassign value via property. obj.name = "Doe"
Removing Data Delete property from object. delete obj.name
Security JSON Injection Sanitize inputs to prevent injection attacks. -
Escape Characters Escape special characters like newline (\n), tab (\t). "message": "Line1\nLine2"
Validation JSON Validators Use tools like JSONLint for validation. -
JSON Schema Enforce structure and rules using schemas. See: json-schema.org
Best Practices No Comments JSON does not support comments. ❌ // Not allowed in JSON
Consistent Keys Use camelCase or snake_case consistently. "firstName": "Alice"
Minified vs Pretty Minify for storage, prettify for readability. JSON.stringify(obj, null, 2)
Common Issues Trailing Comma Will break parsers. Avoid: { "key": "val", }
Improper Quotes Use double quotes ", not single '. βœ… "key" ❌ 'key'
Invalid Values NaN, Infinity, and undefined are invalid. -
Libraries JavaScript JSON.parse(), JSON.stringify() -
Python json.loads(), json.dumps() import json
Other Languages Use Gson (Java), Newtonsoft.Json (.NET), fastjson (Go), etc. -
APIs & Integration REST APIs JSON is commonly used for request/response payloads. Content-Type: application/json
Headers Set header to let server know you're sending/expecting JSON. Accept: application/json
Debugging Browser Tools Use DevTools β†’ Network tab β†’ Preview/Response. Chrome, Firefox
Online Formatters Tools like jsonformatter.org -
Advanced JSON Web Token (JWT) Secure token format with Base64-encoded JSON parts. header.payload.signature
JSONP For legacy cross-domain requests using script tags. callback({ "data": "ok" })
Protobuf (vs JSON) JSON is human-readable; protobuf is faster and compact (used in gRPC). -

πŸ“Ž Quick Tip: Always validate your JSON before using it in your app to avoid hidden bugs! Use https://jsonlint.com or browser dev tools.

πŸ“˜ Suggested Learning:


πŸ’¬ "Bookmark this cheatsheet for daily JSON work. Clean, concise, and built to be your JSON best friend!"

@Sharique55
Copy link
Author

πŸš€ The most comprehensive JSON Cheatsheet you’ll ever need. Perfect for devs, API lovers, and anyone who deals with structured data.

@Sharique55
Copy link
Author

A super extensive, well-organized, and deeply detailed JSON Cheatsheet. Covers all essential categories, syntax rules, nested structures, data types, operations, validation, real-world integration, and advanced usage. Ideal for developers working with JSON in APIs, configs, web apps, and data interchange. Save this as your go-to Gist reference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment