# parse\_json

Parses a JSON string into a Liquid object. Useful when working with API responses, stored data, or metafield values that are JSON-encoded strings.

```liquid
{% assign data = '{"name": "John", "age": 30}' | parse_json %}
{% log data.name %}
```

Output:

```
John
```

#### Syntax

```liquid
{{ json_string | parse_json }}
```

| Parameter     | Description                  |
| ------------- | ---------------------------- |
| `json_string` | A valid JSON string to parse |

#### Return Value

Returns a Liquid object (hash, array, string, number, or boolean) depending on the JSON content.

#### Examples

**Parse a JSON string:**

```liquid
{% assign product_data = '{"title": "T-Shirt", "price": 29.99}' | parse_json %}
{% log product_data.title %}
{% log product_data.price %}
```

**Parse a metafield value:**

```liquid
{% assign config = product.metafields.custom.settings.value | parse_json %}
{% log config.color %}
```

**Parse an API response body:**

```liquid
{% assign response_data = http_result.body | parse_json %}
{% for item in response_data.results %}
  {% log item.name %}
{% endfor %}
```

**Parse stored JSON from file storage:**

```liquid
{% storage_read filename:"config.json" as file_content %}
{% assign config = file_content | parse_json %}
{% log config.api_key %}
```

**Parse a JSON array:**

```liquid
{% assign items = '[1, 2, 3, 4, 5]' | parse_json %}
{% for item in items %}
  {% log item %}
{% endfor %}
```

#### Notes

* Throws an error if the input is not valid JSON
* For building JSON objects, use the `{% json %}` tag instead
* See also: `parse_csv`, `parse_xml`
