You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON-aliased VARCHAR columns are returned as escaped strings instead of nested JSON in API responses #38
When an endpoint returns a column whose DuckDB type is JSON (a logical-type alias over VARCHAR), flAPI serialises it as a JSON-escaped string in the HTTP response instead of embedding the parsed object/array. The consumer then has to do a second JSON.parse on the string, which defeats the point of typing the column as JSON.
Our actual data is a recursive tree (spare parts with children arrays), so we can't really hand-write a from_json schema for it. The source column in BigQuery is typed JSON, and we'd appreciate for the API to just return it as JSON.
(Probable) Root cause
In src/query_executor.cpp, QueryResult::convertVectorEntryToJson dispatches on duckdb_get_type_id(type), which is the physical type id. DuckDB's JSON type is a logical alias over VARCHAR, so the dispatch picks the DUCKDB_TYPE_VARCHAR branch:
cpp case DUCKDB_TYPE_VARCHAR: return convertVectorVarcharToJson(vector, row_idx);
convertVectorVarcharToJson returns:
cpp return crow::json::wvalue(str);
Crow then JSON-escapes that string when serialising the response, producing the behaviour above.
flAPI already serialises native nested types correctly (convertVectorStructToJson, convertVectorListToJson, convertVectorMapToJson), so the only thing missing is detection of the JSON logical-type alias before falling through to VARCHAR.
Environment
flAPI: main (also reproduced on the latest release at the time of writing)
Hi @ritaalves-zoi — thanks so much for the report, and thanks for using flAPI! The write-up was exemplary: minimal reproduction, expected vs. actual response, and a root-cause analysis that pointed straight at the dispatch site in convertVectorEntryToJson. That made the fix a tight TDD loop rather than a hunt.
The fix is now on main via #39 and will ship in the next tag (v26.05.20). JSON-aliased VARCHAR columns are now embedded as nested JSON, so your recursive parts tree should come back through the API ready to consume without a second JSON.parse. Malformed JSON in a source row degrades gracefully to the raw string instead of nulling the cell, and a pre-existing per-cell logical-type leak in the same function got cleaned up along the way.
If you bump into anything else - bug, papercut, or just an idea for making flAPI nicer to develop against or to deploy (CLI ergonomics, project scaffolding, observability, containerization story, CI integration, whatever has been slowing your team down) - please open an issue. We genuinely value field-driven feedback like this; it's how the rough edges get found.
Activity
fix: Embed JSON-aliased VARCHAR columns as nested JSON (#38)
jrosskopf commentedon May 21, 2026
Hi @ritaalves-zoi — thanks so much for the report, and thanks for using flAPI! The write-up was exemplary: minimal reproduction, expected vs. actual response, and a root-cause analysis that pointed straight at the dispatch site in
convertVectorEntryToJson. That made the fix a tight TDD loop rather than a hunt.The fix is now on
mainvia #39 and will ship in the next tag (v26.05.20). JSON-aliased VARCHAR columns are now embedded as nested JSON, so your recursive parts tree should come back through the API ready to consume without a secondJSON.parse. Malformed JSON in a source row degrades gracefully to the raw string instead of nulling the cell, and a pre-existing per-cell logical-type leak in the same function got cleaned up along the way.If you bump into anything else - bug, papercut, or just an idea for making flAPI nicer to develop against or to deploy (CLI ergonomics, project scaffolding, observability, containerization story, CI integration, whatever has been slowing your team down) - please open an issue. We genuinely value field-driven feedback like this; it's how the rough edges get found.