# json

The `json` statement is used to format JSON in a [named buffer](https://github.com/exivity/docs/tree/60a265079e19e329e990b94f7836ea2024c5f214/extract/language/basics/README.md#named_buffers.md).

## Syntax

**`json format`***`{buffername}`*

## Details

In many cases an API or other external source will return JSON in a densely packed format which is not easy for the human eye to read. The `json` statement is used to re-format JSON data that has been previously loaded into a named buffer (via the [buffer](https://olddocs.exivity.io/data-pipelines/extract/language/buffer) statement) into a form that is friendlier to human eyes.

{% hint style="info" %}
After the JSON has been formatted, the buffer can be [saved](https://olddocs.exivity.io/data-pipelines/extract/language/save) or [printed](https://olddocs.exivity.io/data-pipelines/extract/language/print) for subsequent inspection
{% endhint %}

## Example

Given the following single packed line of JSON in a named buffer called *myJSON*:

```javascript
{"title":"Example JSON data","heading":{"category":"Documentation","finalised":true},"items":[{"id":"01","name": "Item number one","subvalues":{"0":1,"10":42,"100":73,"1000":100},"category":"Example data","subcategory":"First array"},{"id":"02","name":"Item number two","subvalues":{"0":10,"10":442,"100":783,"1000":1009},"category":"Example data","subcategory":"First array"}]}
```

The following USE script fragment:

```
json format {myJSON}
print {myJSON}
```

will result in the following output:

```javascript
{
  "title": "Example JSON data",
  "heading": {
    "category": "Documentation",
    "finalised": true
  },
  "items": [
    {
      "id": "01",
      "name": "Item number one",
      "subvalues": {
        "0": 1,
        "10": 42,
        "100": 73,
        "1000": 100
      },
      "category": "Example data",
      "subcategory": "First array"
    },
    {
      "id": "02",
      "name": "Item number two",
      "subvalues": {
        "0": 10,
        "10": 442,
        "100": 783,
        "1000": 1009
      },
      "category": "Example data",
      "subcategory": "First array"
    }
  ]
}
```
