feat: add JSON and NDJSON input/output format support#118
Merged
Conversation
- Add InputFormat and OutputFormat enums (csv, json, ndjson) - Add -I/--input-format and -O/--output-format flags; --json alias preserved - Add loadJsonArray: reads full JSON array from stdin, inserts into SQLite - Add loadNdjsonInput: streams NDJSON line-by-line into SQLite - Add bindJsonValue: maps std.json.Value variants to SQLite bind calls - Add insertRowFromJson: binds a JSON object row by column name - Add printNdjsonRow: writes one NDJSON object per result row - Add printJsonRow/printNdjsonRow output path in execQuery - Use SQLITE_STATIC for all string bindings; deferred_allocs tracks serialized array/object strings so they outlive sqlite3_step - Add 14 integration tests (48-61) covering JSON/NDJSON roundtrips, null values, nested objects, empty arrays, --columns, error paths
…ules Move @cImport to src/c.zig so all modules share a single opaque sqlite3 type. Extract bindJsonValue, insertRowFromJson, readLine, loadJsonArray, loadNdjsonInput, writeJsonString, printJsonRow and printNdjsonRow from main.zig into src/json.zig. Fix ziglint violations in json.zig (Z023, Z017, Z026).
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-I/--input-formatand-O/--output-formatflags withcsv,json,ndjsonvalues;--jsonalias preserved for backward compatibilitystd.json, inserts rows with type-aware SQLite bindingsexecQuerydispatches toprintJsonRow/printNdjsonRowper result row--columns, and error pathsNotes
TEXTin SQLite; integer/float/bool/null values are bound via their native SQLite bind functionsSQLITE_STATICwith adeferred_allocslist to keep allocations alive pastsqlite3_step--headerremains mutually exclusive with non-CSV output formats