sqlx-json 0.12.0

Database-agnostic row-to-JSON conversion for sqlx
Documentation

sqlx-json

Crates.io Docs.rs CI License: MIT

One trait, three backends. Turn any sqlx row into a serde_json::Value without writing per-column match arms. Built for dbmcp — the single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite.

What you get

  • RowExt::to_json() for SqliteRow, PgRow, and MySqlRow
  • Null-aware — NULL columns become Value::Null, never panic
  • Binary-safe — BYTEA / BLOB / VARBINARY base64-encoded
  • Precision-safe — numeric / decimal go through BigDecimal
  • JSON / JSONB columns parsed and inlined as real JSON, not stringified
  • QueryResult trait exposes .rows_affected() generically across backends
  • Tiny surface — one trait, two methods, no macros

See the main crate: dbmcp · Website · Docs