JcHub
Cheat sheetFree, no sign-upPDF

JSON Cheat Sheet: Syntax, Data Types, and Best Practices

A comprehensive cheat sheet on JSON syntax, data types, and common pitfalls to structure your data and integrate APIs efficiently.

Updated on November 24, 2026

Basic Syntax

  • {"name": "Kone", "age": 30}A JSON object starts and ends with braces containing key-value pairs. Trap: keys must always be enclosed in double quotes.
  • ["Dakar", "Abidjan", "Douala"]A JSON array uses brackets to store an ordered list of items. Trap: trailing commas at the end of the last item are invalid.
  • "city": "Brazzaville"Associates a string key with a value. Trap: using single quotes instead of double quotes causes a fatal syntax error.
  • // Comments not allowedJSON does not support native comments. Trap: adding comments will crash the JSON parser of your application.
  • { "user": null }Represents a null or empty value. Trap: do not confuse null with an empty string like "".

Accepted Data Types

  • "amount": 15000Numbers do not use quotes, whether they are integers or decimals. Trap: numbers cannot start with a leading zero.
  • "active": trueBooleans must be lowercase and set to either true or false. Trap: capitalizing them as True or False makes the file invalid.
  • "coordinates": {"lat": 4.05}An object can contain another object to structure complex data. Trap: avoid creating excessively deep nesting levels.
  • "payment": ["Mobile Money", "Card"]An array can hold a list of other arrays or objects. Trap: array items should maintain a consistent data structure.
  • "phone": "+237600000000"Strings must strictly use double quotes. Trap: always escape internal quotes using a backslash.

Validation and Formatting

  • JSON Formatter & ValidatorUse this JcHub tool to check syntax and format your JSON files. Trap: a single missing character breaks the entire API response.
  • JSON.parse(response)Converts a JSON string into a manipulable JavaScript object. Trap: throws an error if the received string is malformed.
  • JSON.stringify(data)Turns a JavaScript object into a JSON string for transmission. Trap: functions and undefined values are ignored.
  • try { JSON.parse(x) } catch(e) {}Catches syntax errors when parsing external data. Trap: never parse external data without implementing error handling.

Integration and Best Practices

  • Content-Type: application/jsonMandatory HTTP header to specify the data format of an API. Trap: omitting it often triggers a server error.
  • "date": "2023-10-25T10:00:00Z"ISO 8601 format is recommended for storing and exchanging dates. Trap: avoid sending non-serialized native date objects.
  • "price": 1500.50Use numbers for monetary amounts in APIs. Trap: avoid commas for decimals, always use a dot.

Other resources

Need help with your website?

I build your custom website.

Showcase site, online shop, management tool: let’s talk about your project.

See the services