Exploring the power of JSON: a real-life JSON file example collection

| 5 min read

Who doesn’t love a JSON file example? The examples in this article are free to use. You can check them out to understand what a JSON file should look like and how to write a JSON file yourself. You can also use them if you need some example data for testing or debugging. There are some large files included to be able to do performance tests for example.

A JSON object

Here is a basic JSON example. It is an object with three properties: a name, age, and city. Note that the age is a numeric value, and the other properties are strings enclosed in quotes.

loading...

A JSON array with objects

The following example shows an array or a list with objects:

loading...

Each of the objects has three properties and is the same as the object in the previous example. It looks different, but that is only because all properties are formatted on the same line. In JSON, you can add whitespaces and newlines between keys and values as you like, they do not change the meaning of the data.

A nested JSON example

JSON Objects and arrays can contain nested objects and arrays. You can have multiple nesting levels. This is explained in detail in the article “What is JSON? Learn all about JSON in 5 minutes”.

In the following example you see a JSON object containing a list with friends. Each friend is an object, and this object again contains a nested array with the friend’s hobbies.

loading...

A JSON example with a date

The JSON data format does not support a date type. There are different ways to have a date in a JSON document. The most common one is to represent the date as a human-readable string, using the ISO Date format (In JavaScript you can try new Date().toISOString()):

loading...

A JSON example with colors

Like dates, JSON does not have a data type. You can put an HTML color or hex color code a string:

loading...

A large JSON document

For development purposes, it can be handy to have a large JSON document around to test performance for example. You can download one of the following auto-generated JSON documents (after downloading, you can open them in JSON Editor Online to inspect them):

Preview with 10 users:

loading...

A GeoJSON example

Physical locations on earth are described with two coordinates: a longitude and a latitude. The longitude (horizontal) is zero degrees at Greenwich, and varies from -180 degrees West to 180 degrees East. The latitude (vertical) is 0 degrees at the equator, and varies from -90 degrees on the South pool to 90 degrees on the North pool.

There is no standard way to model a GEO location in JSON. You may see an object like { "lat": 51.908, "lon": 4.485 } or { "lat": 51.908, "lng": 4.485 } or { "latitude": 51.908, "longitude": 4.485 }. Or you may see an array with two values: [ 4.485, 51.908 ] or [ 51.908, 4.485 ]. Which of the two values in the array is the latitude and which is the longitude differs for different applications, so be careful.

Using the GeoJSON standard, you can describe points, lines, and polygons. These shapes can be rendered on a map. Here is an example:

loading...

A JSON Schema example

JSON Schema is a JSON based language to describe a data structure. You can read all about it in the article “JSON Schema validator: a powerful way to check JSON data”. The following example from this article describes a data structure that is an array with objects, each object having a required property name and age, and an optional property email.

JSON Schema
loading...
JSON
loading...
The JSON document is valid according to the JSON Schema

A YouTube JSON example

You may be thinking “all these examples are nice, but they are made up. How does real JSON from real API’s look like?”. Let us have a look at the YouTube API. We can search for YouTube videos using an HTTP GET request. Let us search for videos about “football”. If we only provide the query parameter q, we will get a list with video id’s. To also receive the title and description of the videos, we add the query parameter part=snippet:

GET https://www.googleapis.com/youtube/v3/search?q=football&part=snippet

Note that you’ll have to provide a valid Authentication header in the HTTP GET request from the server. This is explained in the documentation of the YouTube API, where you can also try this out on the fly.

The response is as follows. It is quite deeply nested, but basically it contains some generic information the first page of a list with videos. Each video contains an object with details like the id, but also the title, description, and channel information.

loading...

More JSON datasets

Here some links to more JSON datasets and resources: