Skip to main content
Glama
kzmshx
by kzmshx
0006-json-encode-arrays.md854 B
# 6. JSON encode arrays Date: 2025-11-28 ## Status Accepted ## Context We needed to decide how to handle frontmatter arrays (e.g., `tags: [ai, python]`) in DuckDB. Since ADR-0005 established treating all values as strings, arrays also needed some string representation. ## Decision Arrays are JSON-encoded as strings, and expanded on the SQL side using `from_json()` and `UNNEST`. ```python # Python side if isinstance(value, list): return json.dumps(value, ensure_ascii=False) ``` ```sql -- SQL side expansion SELECT path, tag FROM files, UNNEST(from_json(tags, '[""]')) AS t(tag) ``` ## Consequences - Consistent with ADR-0005's all-strings approach - All columns unified as string type - Arrays can be dynamically converted using DuckDB's `from_json()` function - `from_json()` requires a schema hint as the second argument (`'[""]'`)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kzmshx/frontmatter-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server