{"id":20029176,"url":"https://github.com/jsonjoy-com/json-expression","last_synced_at":"2026-02-14T03:32:24.514Z","repository":{"id":257811690,"uuid":"868180058","full_name":"jsonjoy-com/json-expression","owner":"jsonjoy-com","description":"JSON Expression implementation with JIT compilation","archived":false,"fork":false,"pushed_at":"2025-08-24T12:34:33.000Z","size":1455,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-28T20:44:16.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsonjoy-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":"streamich"}},"created_at":"2024-10-05T17:22:05.000Z","updated_at":"2025-09-23T23:42:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"c44fde63-9b4a-43cc-80e0-171b45982c1b","html_url":"https://github.com/jsonjoy-com/json-expression","commit_stats":null,"previous_names":["jsonjoy-com/json-expression"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jsonjoy-com/json-expression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonjoy-com%2Fjson-expression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonjoy-com%2Fjson-expression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonjoy-com%2Fjson-expression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonjoy-com%2Fjson-expression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonjoy-com","download_url":"https://codeload.github.com/jsonjoy-com/json-expression/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonjoy-com%2Fjson-expression/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29433933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T02:20:56.896Z","status":"ssl_error","status_checked_at":"2026-02-14T02:11:29.478Z","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":[],"created_at":"2024-11-13T09:18:46.880Z","updated_at":"2026-02-14T03:32:24.506Z","avatar_url":"https://github.com/jsonjoy-com.png","language":"TypeScript","funding_links":["https://github.com/sponsors/streamich"],"categories":[],"sub_categories":[],"readme":"# JSON Expression\n\n[JSON Expression](https://jsonjoy.com/specs/json-expression) is an s-expression based language for JSON. It is designed to\nbe a more human-readable and writable alternative to JSON. It uses JSON as its\ndata model and syntax.\n\nJSON Expressions are JIT compiled to efficient machine code.\n\nJSON Expression is a simple JSON DSL, which allows to write expressions and\nevaluate expressions.\n\nFor example, the following expression\n\n```js\n['+', 1, 2]; // 1 + 2\n```\n\nevaluates to 3.\n\n\n## Usage\n\n`json-expression` library can immediately evaluate expressions or it can\ncompile an efficient expression to a function, which will execute about\nan order of magnitude faster.\n\nEvaluating expression immediately as-is.\n\n```ts\nimport {evaluate} from '@jsonjoy.com/json-expression';\n\nconst expression = ['+', 1, ['$', '/foo']];\nconst data = {foo: 2};\n\nevaluate(expression, {data}); // 3\n```\n\nPre-compiling expression to an optimized function.\n\n```ts\nimport {JsonExpressionCodegen} from '@jsonjoy.com/json-expression';\n\nconst expression = ['+', 1, ['$', '/foo']];\nconst codegen = new JsonExpressionCodegen({expression});\nconst fn = codegen.run().compile();\nconst data = {foo: 2};\n\nfn({data}); // 3\n```\n\n\n## Documentation\n\n`json-expression` library supports few dozen operators, see full list in `Expr`\ntype [here](./types.ts).\n\nParsing rules:\n\n1. JSON Expression is a valid JSON value.\n2. All expressions are JSON arrays, which start with a string which specifies\n   the operator and remaining array elements are operands. For example, the\n   \"get\" operator fetches some value from supplied data using JSON\n   Pointer:`[\"get\", \"/some/path\"]`.\n3. All other values are treated as literals. Except for arrays, which need to\n   be enclosed in square brackets. For example, to specify an empty array, you\n   box your array in square brackets: `[[]]`. This evaluates to an empty array\n   JSON value `[]`.\n\n\n## Use Cases\n\nConsider you application receives a stream of JSON Cloud Events, like this:\n\n```js\n{\n  \"specversion\" : \"1.0\",\n  \"type\" : \"com.example.someevent\",\n  \"source\" : \"/mycontext\",\n  \"subject\": null,\n  \"id\" : \"C234-1234-1234\",\n  \"time\" : \"2018-04-05T17:31:00Z\",\n  \"comexampleextension1\" : \"value\",\n  \"comexampleothervalue\" : 5,\n  \"datacontenttype\" : \"application/json\",\n  \"data\" : {\n      \"appinfoA\" : \"abc\",\n      \"appinfoB\" : 123,\n      \"appinfoC\" : true\n  }\n}\n```\n\nYou could write and compile a JSON Expression to efficiently filter out events\nyou are interested in, for example your expression could look like this:\n\n```js\n[\n  'and',\n  ['==', ['$', '/specversion'], '1.0'],\n  ['starts', ['$', '/type'], 'com.example.'],\n  ['in', ['$', '/datacontenttype'], [['application/octet-stream', 'application/json']]],\n  ['==', ['$', '/data/appinfoA'], 'abc'],\n];\n```\n\n\n## Benchmark\n\n```\nnode benchmarks/json-expression/main.js\njson-joy/json-expression JsonExpressionCodegen x 14,557,786 ops/sec ±0.09% (100 runs sampled), 69 ns/op\njson-joy/json-expression JsonExpressionCodegen with codegen x 170,098 ops/sec ±0.13% (101 runs sampled), 5879 ns/op\njson-joy/json-expression evaluate x 864,956 ops/sec ±0.10% (101 runs sampled), 1156 ns/op\njson-logic-js x 821,799 ops/sec ±0.18% (99 runs sampled), 1217 ns/op\nFastest is json-joy/json-expression JsonExpressionCodegen\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonjoy-com%2Fjson-expression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonjoy-com%2Fjson-expression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonjoy-com%2Fjson-expression/lists"}