{"id":47588439,"url":"https://github.com/h22rana/jsonlogic2sql","last_synced_at":"2026-04-01T16:56:23.808Z","repository":{"id":318824495,"uuid":"1076574443","full_name":"h22rana/jsonlogic2sql","owner":"h22rana","description":"JSON Logic to SQL Transpiler","archived":false,"fork":false,"pushed_at":"2026-03-27T06:43:16.000Z","size":80717,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-27T07:53:06.333Z","etag":null,"topics":["go","golang","jsonlogic","sql","transpilation","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/h22rana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-15T03:58:07.000Z","updated_at":"2026-03-23T12:32:33.000Z","dependencies_parsed_at":"2025-10-16T12:15:56.206Z","dependency_job_id":"8616a03e-d1e3-422c-bc48-cb3189ea6d22","html_url":"https://github.com/h22rana/jsonlogic2sql","commit_stats":null,"previous_names":["h22rana/jsonlogic2sql"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/h22rana/jsonlogic2sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h22rana%2Fjsonlogic2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h22rana%2Fjsonlogic2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h22rana%2Fjsonlogic2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h22rana%2Fjsonlogic2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h22rana","download_url":"https://codeload.github.com/h22rana/jsonlogic2sql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h22rana%2Fjsonlogic2sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","jsonlogic","sql","transpilation","transpiler"],"created_at":"2026-04-01T16:56:23.180Z","updated_at":"2026-04-01T16:56:23.789Z","avatar_url":"https://github.com/h22rana.png","language":"Go","readme":"# JSON Logic to SQL Transpiler\n\nA Go library that converts JSON Logic expressions into SQL. This library provides a clean, type-safe API for transforming JSON Logic rules into SQL WHERE clauses or standalone conditions, with support for multiple SQL dialects.\n\n## Features\n\n- **Complete JSON Logic Support**: Implements all core JSON Logic operators\n- **SQL Dialect Support**: Target BigQuery, Spanner, PostgreSQL, DuckDB, or ClickHouse\n- **Parameterized Queries**: Generate SQL with bind placeholders (`@p1`, `$1`) and separate parameter values for safe execution\n- **Custom Operators**: Extensible registry pattern for custom SQL functions\n- **Schema Validation**: Optional field schema for strict column validation\n- **Structured Errors**: Error codes and JSONPath locations for debugging\n- **Library \u0026 CLI**: Both programmatic API and interactive REPL\n\n## Quick Start\n\n```bash\ngo get github.com/h22rana/jsonlogic2sql@latest\n```\n\n### Inline SQL\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/h22rana/jsonlogic2sql\"\n)\n\nfunc main() {\n    sql, err := jsonlogic2sql.Transpile(\n        jsonlogic2sql.DialectBigQuery,\n        `{\"\u003e\": [{\"var\": \"amount\"}, 1000]}`,\n    )\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(sql) // Output: WHERE amount \u003e 1000\n}\n```\n\n### Parameterized Queries\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/h22rana/jsonlogic2sql\"\n)\n\nfunc main() {\n    sql, params, err := jsonlogic2sql.TranspileParameterized(\n        jsonlogic2sql.DialectBigQuery,\n        `{\"and\": [{\"==\": [{\"var\": \"status\"}, \"active\"]}, {\"\u003e\": [{\"var\": \"amount\"}, 1000]}]}`,\n    )\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(sql)    // Output: WHERE (status = @p1 AND amount \u003e @p2)\n    fmt.Println(params) // Output: [{p1 active} {p2 1000}]\n}\n```\n\n## Supported Operators\n\n| Category | Operators |\n|----------|-----------|\n| **Data Access** | `var`, `missing`, `missing_some` |\n| **Comparison** | `==`, `===`, `!=`, `!==`, `\u003e`, `\u003e=`, `\u003c`, `\u003c=` |\n| **Logical** | `and`, `or`, `!`, `!!`, `if` |\n| **Numeric** | `+`, `-`, `*`, `/`, `%`, `max`, `min` |\n| **Array** | `in`, `map`, `filter`, `reduce`, `all`, `some`, `none`, `merge` |\n| **String** | `in`, `cat`, `substr` |\n\n## Supported Dialects\n\n| Dialect | Constant |\n|---------|----------|\n| Google BigQuery | `DialectBigQuery` |\n| Google Cloud Spanner | `DialectSpanner` |\n| PostgreSQL | `DialectPostgreSQL` |\n| DuckDB | `DialectDuckDB` |\n| ClickHouse | `DialectClickHouse` |\n\n## Documentation\n\n- [Getting Started](docs/getting-started.md) - Installation and basic usage\n- [Parameterized Queries](docs/parameterized-queries.md) - Bind-parameter output for safe SQL execution\n- [Operators](docs/operators.md) - All supported operators with examples\n- [SQL Dialects](docs/dialects.md) - Dialect-specific SQL generation\n- [Custom Operators](docs/custom-operators.md) - Extend with your own operators\n- [Schema Validation](docs/schema-validation.md) - Field validation and type checking\n- [Examples](docs/examples.md) - Comprehensive examples\n- [API Reference](docs/api-reference.md) - Full API documentation\n- [Error Handling](docs/error-handling.md) - Error codes and programmatic handling\n- [Development](docs/development.md) - Contributing and development guide\n- [REPL](docs/repl.md) - Interactive testing tool\n- [WASM Playground](docs/wasm-playground.md) - Browser-based demo via WebAssembly\n\n## Important Notes\n\n\u003e **Semantic Correctness Assumption:** This library assumes that the input JSONLogic is semantically correct. The transpiler generates SQL that directly corresponds to the JSONLogic structure without validating the logical correctness of the expressions.\n\n\u003e **SQL Injection:** This library includes hardening measures against SQL injection - identifier names are validated against a whitelist pattern, string literals are escaped, and numeric string operands are safely coerced. For maximum safety, use the [parameterized query API](docs/parameterized-queries.md) which generates SQL with bind placeholders instead of inlined literals.\n\n## Interactive REPL\n\n```bash\nmake run\n```\n\n```\n[BigQuery] jsonlogic\u003e {\"\u003e\": [{\"var\": \"amount\"}, 1000]}\nSQL: WHERE amount \u003e 1000\n\n[BigQuery] jsonlogic\u003e :params\nParameterized mode: ON (output uses bind placeholders)\n\n[BigQuery] jsonlogic\u003e {\"==\": [{\"var\": \"status\"}, \"active\"]}\nSQL:    WHERE status = @p1\nParams: [{p1: \"active\"}]\n\n[BigQuery] jsonlogic\u003e :dialect\nSelect dialect: PostgreSQL\n\n[PostgreSQL] jsonlogic\u003e {\"merge\": [{\"var\": \"a\"}, {\"var\": \"b\"}]}\nSQL: WHERE (a || b)\n```\n\n## Development\n\n```bash\nmake test       # Run all tests (3,000+ test cases)\nmake bench      # Run benchmarks\nmake build      # Build REPL binary\nmake build/wasm # Build WASM binary for browser playground\nmake lint       # Run linter\nmake run        # Run REPL\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh22rana%2Fjsonlogic2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh22rana%2Fjsonlogic2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh22rana%2Fjsonlogic2sql/lists"}