{"id":42920,"library":"json-sql-utility","title":"json-sql-utility","description":"A lightweight utility for converting JSON objects to SQL SELECT queries. Currently at version 1.1.4, it supports SELECT statements with fields, aggregations, WHERE clauses (including logical operators, date ranges), GROUP BY, ORDER BY, and misc clauses. It is not actively maintained and only supports SELECT queries; INSERT, UPDATE, DELETE are absent. Simpler than alternatives like json-sql or squel, but with limited features.","status":"active","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/ppiyush13/json-sql-utility","tags":["javascript","json sql","json to sql","json 2 sql","jsonSql","json2sql","jsonToSql","json-2-sql","json-to-sql"],"install":[{"cmd":"npm install json-sql-utility","lang":"bash","label":"npm"},{"cmd":"yarn add json-sql-utility","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-sql-utility","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require is not supported. The package has no default export.","wrong":"const select = require('json-sql-utility')","symbol":"select","correct":"import { select } from 'json-sql-utility'"},{"note":"If using CommonJS, destructure from require. Default import is incorrect.","wrong":"import select from 'json-sql-utility'","symbol":"select","correct":"const { select } = require('json-sql-utility')"},{"note":"Wildcard import works, but only the `select` function is exported.","wrong":"import * as sql from 'json-sql-utility'","symbol":"select","correct":"import { select } from 'json-sql-utility'"}],"quickstart":{"code":"import { select } from 'json-sql-utility';\n\nconst query = select({\n  fields: ['A', 'B'],\n  aggregation: [\n    {\n      fn: 'count',\n      args: 'D',\n      alias: 'CNT'\n    }\n  ],\n  from: 'STUDENTS',\n  where: [\n    {\n      operator: 'equal',\n      field: 'NAME',\n      value: 'Piyush'\n    },\n    {\n      operator: '=',\n      field: 'ROLL',\n      value: [13],\n    },\n    {\n      operator: 'OR',\n      conditions: [\n        {\n          operator: 'equal',\n          field: 'A',\n          value: 5,\n        },\n        {\n          operator: 'equal',\n          field: 'A',\n          value: 10,\n        }\n      ]\n    },\n    {\n      operator: 'dateBetween',\n      field: 'BIRTH',\n      value: {\n        start: new Date(1975, 0, 1),\n        end: new Date(1999, 11, 31),\n      }\n    },\n  ],\n  groupBy: ['A', 'B', 'C'],\n  orderBy: ['A'],\n  misc: [\n    \"EXTERNAL NAME 'TestFuncs$MyMath.pow'\"\n  ],\n});\n\nconsole.log(query);","lang":"javascript","description":"Builds a SELECT SQL query from a JSON object with fields, aggregation, WHERE conditions, grouping, ordering, and misc clauses."},"warnings":[{"fix":"Use a different library like knex.js or json-sql for full SQL support.","message":"The package only supports SELECT queries. Trying to build INSERT, UPDATE, or DELETE will fail or produce garbage.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Check the source or documentation for supported operators. Only a limited set is implemented.","message":"The `where` operator names use strings like 'equal', '=', 'dateBetween', etc. Using an unsupported operator will silently produce invalid SQL.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass dates as ISO strings (e.g., '1975-01-01') to ensure consistent formatting.","message":"Date values in where conditions are serialized using toLocaleDateString, which may produce locale-dependent strings like '1/1/1975'. This may not match your SQL dialect's expected format.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Sanitize inputs manually or migrate to a maintained alternative.","message":"The package has not been updated since 2020. There are known issues with SQL injection if using raw values.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'-2':82 '1.1.4':19 '2':76 'absent':55 'activ':44 'aggreg':26 'altern':58 'claus':28,40 'convert':9 'current':16 'date':32 'delet':53 'featur':68 'field':25 'group':34 'includ':29 'insert':51 'javascript':69 'json':2,10,61,70,72,75,81,85 'json-sql':60 'json-sql-util':1 'json-to-sql':84 'json2sql':79 'jsonsql':78 'jsontosql':80 'lightweight':6 'like':59 'limit':67 'logic':30 'maintain':45 'misc':39 'object':11 'oper':31 'order':36 'queri':15,50 'rang':33 'select':14,22,49 'simpler':56 'sql':3,13,62,71,74,77,83,87 'squel':64 'statement':23 'support':21,48 'updat':52 'util':4,7 'version':18","created_at":"2026-06-05T16:57:18.178233+00:00","updated_at":"2026-06-05T16:57:18.178233+00:00","problems":[{"fix":"Use `import { select } from 'json-sql-utility'`","cause":"Importing default export instead of named export.","error":"TypeError: select is not a function"},{"fix":"Use `import { select } from 'json-sql-utility'`","cause":"Using require in an ESM environment.","error":"ReferenceError: require is not defined"},{"fix":"Use `const { select } = require('json-sql-utility')`","cause":"Using CommonJS require incorrectly (e.g., `const sql = require('json-sql-utility'); sql.select(...)` but the package has no default export).","error":"SyntaxError: Unexpected token '.'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ppiyush13/json-sql-utility","github":"https://github.com/ppiyush13/json-sql-utility","docs":null,"changelog":null,"pypi":null,"npm":"json-sql-utility","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}