# 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](/2.10.2/data-pipelines/extract/language/buffer.md) statement) into a form that is friendlier to human eyes.

{% hint style="info" %}
After the JSON has been formatted, the buffer can be [saved](/2.10.2/data-pipelines/extract/language/save.md) or [printed](/2.10.2/data-pipelines/extract/language/print.md) 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"
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olddocs.exivity.io/2.10.2/data-pipelines/extract/language/json.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
