# JSON

JSON is Stof's closest relative format. The Stof parser accepts JSON field & object syntax (most JSON files can be considered Stof).

Stof, unlike JSON, is not limited to just fields of data, however. Because of this, the JSON format implementation is a lossy export, but captures everything on import.

{% hint style="info" %}
Take a look at [Imports](/advanced-features/imports.md) and [Exports](/advanced-features/exports.md) if you haven't already.
{% endhint %}

{% tabs %}
{% tab title="test.json" %}

```json
{
    "message": "hello, world",
    "person": {
        "name": "Bob Smith",
        "age": 42
    }
}
```

{% endtab %}

{% tab title="test.stof" %}

```rust
import "./test.json"; // uses "json" format

#[main]
fn main() {
    assert_eq(self.message, "hello, world");
    assert_eq(self.person.name, "Bob Smith");
    assert_eq(self.person.age, 42);
    
    const json = stringify("json", self); // string export (fields only)
    assert_eq(json, '{"message":"hello, world","person":{"name":"Bob Smith","age":42}}');
}
```

{% endtab %}
{% endtabs %}


---

# 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://docs.stof.dev/formats/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.
