🚚 JSON

Packaging data with JavaScript Object Notation

JSON format

An array [] of objects {} containing key-value pairs separated by a colon :


[
	{
		"dish": "Linguine with Pesto",
		"level": "Beginner",
		"ethnicity": "Italian",
		"description": "A favorite from the Ligurian coast made when basil is in season.",
	},
	{
		"dish": "Pad Thai",
		"level": "Intermediate",
		"ethnicity": "Thai",
		"description": "A tangy stir fry from Thailand."
	},
]

JSON format

The labels ("keys") have to be strings, but the contents ("values") can also be numbers, arrays, or objects.


[
	{
		"dish": "Linguine with Pesto",
		...
		"cookingTimeInMinutes": 30,
		"ingredients": ["basil", "olive oil", "linguine", "pine nuts", "garlic"]
	},
	{
		"dish": "Pad Thai",
		...
		"cookingTimeInMinutes": 25,
		"ingredients": ["shrimp", "peanuts", "egg", "sprouts"]
	},
]

JSON format

You can refer to images by setting a label to a string containing a URL path to an uploaded image.


[
	{
		"dish": "Linguine with Pesto",
		...
		"image": "https://example.com/linguine_con_pesto.jpg"
	},
	{
		"dish": "Pad Thai",
		...
		"image": "https://example.com/pad_thai.jpg"
	},
]

Quotemark position

Unlike English grammar, trailing commas go after quotes.


	value", ✅
	value," ❌

Trailing commas

❌ Trailing commas with no entry after them can cause errors.


[
	{
		"dish": "Linguine with Pesto",
		"level": "Beginner", // BAD
	},
	{}.
		"dish": "Pad Thai",
		"level": "Intermediate", // BAD
	}, // BAD
]

✅ Eliminate hanging commas instead:


[
	{
		"dish": "Linguine with Pesto",
		"level": "Beginner"
	},
	{
		"dish": "Pad Thai",
		"level": "Intermediate"
	}
]
Json Fields Cards Diagram No Arrows
Json Fields Cards Diagram No Arrows
Json Fields Cards Diagram Arrow Key
Json Fields Cards Diagram Arrow Key
Json Fields Cards Diagram Arrow Value
Json Fields Cards Diagram Arrow Value

JSON review

/