{"id":15355806,"url":"https://github.com/fibo/sql92-json","last_synced_at":"2025-07-28T16:09:01.485Z","repository":{"id":51416797,"uuid":"81264305","full_name":"fibo/SQL92-JSON","owner":"fibo","description":"can stringify a JSON into an SQL and viceversa parse an SQL and serialize it into a JSON","archived":false,"fork":false,"pushed_at":"2023-03-31T12:32:55.000Z","size":960,"stargazers_count":10,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T09:42:30.150Z","etag":null,"topics":["javascript","json","parser","sql"],"latest_commit_sha":null,"homepage":"https://fibo.github.io/SQL92-JSON","language":"JavaScript","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/fibo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["fibo"],"patreon":"fibo"}},"created_at":"2017-02-07T23:10:52.000Z","updated_at":"2024-06-12T09:34:48.000Z","dependencies_parsed_at":"2022-09-15T01:22:22.097Z","dependency_job_id":null,"html_url":"https://github.com/fibo/SQL92-JSON","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2FSQL92-JSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2FSQL92-JSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2FSQL92-JSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2FSQL92-JSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibo","download_url":"https://codeload.github.com/fibo/SQL92-JSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023619,"owners_count":21199957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","json","parser","sql"],"created_at":"2024-10-01T12:25:42.337Z","updated_at":"2025-04-15T06:38:50.036Z","avatar_url":"https://github.com/fibo.png","language":"JavaScript","readme":"# SQL92-JSON\n\n\u003e can stringify a JSON into a SQL and viceversa parse a SQL statement and serialize it into a JSON\n\n[Installation](#installation) |\n[API](#api) |\n[Examples](#examples) |\n[Recipes](#recipes) |\n[References](#references) |\n[License](#license)\n\n[![NPM version](https://badge.fury.io/js/sql92-json.svg)](http://badge.fury.io/js/sql92-json)\n[![Build Status](https://travis-ci.org/fibo/SQL92-JSON.svg?branch=master)](https://travis-ci.org/fibo/SQL92-JSON?branch=master)\n[![Badge size](https://badge-size.herokuapp.com/fibo/sql92-json/master/dist/sql92-json.min.js)](https://github.com/fibo/sql92-json/blob/master/dist/sql92-json.min.js)\n[![Coverage Status](https://coveralls.io/repos/fibo/SQL92-JSON/badge.svg?branch=master)](https://coveralls.io/r/fibo/SQL92-JSON?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n[![Demo](//g14n.info/SQL92-JSON/demo.png)](//g14n.info/SQL92-JSON/demo)\n\n## Installation\n\n### Using npm\n\nWith [npm](https://npmjs.org/) do\n\n```bash\nnpm install sql92-json\n```\n\n### Using a CDN\n\nAdd this to your HTML page\n\n```html\n\u003cscript src=\"https://unpkg.com/sql92-json/dist/sql92-json.min.js\"\u003e\u003c/script\u003e\n```\n\n## API\n\nBoth CommonJS and ES6 imports are supported. Code snippets below use\n`require`, it is also possible to do\n\n```javascript\nimport { parse, stringify } from 'sql92-json'\n```\n\n### `stringify`\n\n\u003e Convert a JSON to SQL\n\nBoth `require('sql92-json').stringify` and `require('sql92-json/stringify')` are valid.\n\n```javascript\nvar json2sql = require('sql92-json').stringify\n\nconsole.log(json2sql({ SELECT: ['*'], FROM: ['revenue'] }))\n//\n// SELECT *\n// FROM revenue\n//\n```\n\n### `parse`\n\n\u003e Convert an SQL to JSON\n\nBoth `require('sql92-json').parse` and `require('sql92-json/parse')` are valid.\n\n```javascript\nvar sql2json = require('sql92-json').parse\n\nconsole.log(sql2json('SELECT * FROM revenue')\n// {\n//   SELECT: ['*'],\n//   FROM: ['revenue']\n// }\n```\n\n## Recipes\n\n* [Add resultset limit](http://g14n.info/SQL92-JSON/recipes/resultset-limit/) (WiP)\n* [Compute resultset count](http://g14n.info/SQL92-JSON/recipes/resultset-count/)\n* [Prepend pool header](http://g14n.info/SQL92-JSON/recipes/spool-header/)\n* [Table list](http://g14n.info/SQL92-JSON/recipes/table-list/) (PoC)\n\n## Examples\n\nSee [examples] folder where every `.json` file has its homonym `.sql`.\n\nSee for example the following [example JSON][exampleJSON] and its [corresponding SQL][exampleSQL].\n\n```json\n{\n  \"SELECT\": [ { \"COUNT\": \"*\", \"AS\": \"num\" } ],\n  \"FROM\": [\n    {\n      \"SELECT\": [\"*\"],\n      \"FROM\": [\"mytable\"],\n      \"WHERE\": [\n        \"yyyymmdd\", { \"=\": 20170101 },\n        { \"AND\": [ \"country\", { \"IN\": [\"IT\", \"US\"] } ] },\n        { \"AND\": [\n          \"categoryid\", { \"BETWEEN\": [100, 200] },\n          { \"OR\": [ \"productname\", { \"!=\": \"'icecream'\" } ] }\n        ] }\n      ]\n    }\n  ]\n}\n```\n\n```sql\nSELECT COUNT(*) AS num\nFROM (\n\tSELECT *\n\tFROM mytable\n\tWHERE yyyymmdd = 20170101\n\t\tAND country IN ( 'IT', 'US' )\n\t\tAND (\n\t\t\tcategoryid BETWEEN 100 AND 200\n\t\t\tOR productname != 'icecream'\n\t\t)\n)\n```\n\n## References\n\n[sql1992.txt](https://github.com/fibo/SQL92-JSON/blob/master/sql1992.txt) was downloaded from [here](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt).\n\n## License\n\n[MIT](http://g14n.info/mit-license/)\n\n[examples]: https://github.com/fibo/SQL92-JSON/tree/master/examples\n[exampleSQL]: https://github.com/fibo/SQL92-JSON/blob/master/examples/_readme.select.sql\n[exampleJSON]: https://github.com/fibo/SQL92-JSON/blob/master/examples/_readme.select.json\n","funding_links":["https://github.com/sponsors/fibo","https://patreon.com/fibo"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fsql92-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibo%2Fsql92-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fsql92-json/lists"}