{"id":13514899,"url":"https://github.com/schibsted/jslt","last_synced_at":"2025-05-14T20:02:00.574Z","repository":{"id":37318675,"uuid":"136928174","full_name":"schibsted/jslt","owner":"schibsted","description":"JSON query and transformation language","archived":false,"fork":false,"pushed_at":"2024-11-28T08:01:08.000Z","size":1179,"stargazers_count":655,"open_issues_count":110,"forks_count":120,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-13T14:00:03.552Z","etag":null,"topics":["jackson","java","json","language","query","transform"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schibsted.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":"support/jslt.el","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-11T13:11:37.000Z","updated_at":"2025-04-10T18:27:40.000Z","dependencies_parsed_at":"2023-01-25T21:01:14.842Z","dependency_job_id":"4f401883-be3f-4e5c-a5ee-d1054a390a50","html_url":"https://github.com/schibsted/jslt","commit_stats":{"total_commits":457,"total_committers":17,"mean_commits":26.88235294117647,"dds":0.5754923413566739,"last_synced_commit":"40392a22dce955ef6ff77152d8c48ba90065a97d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schibsted%2Fjslt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schibsted%2Fjslt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schibsted%2Fjslt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schibsted%2Fjslt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schibsted","download_url":"https://codeload.github.com/schibsted/jslt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724585,"owners_count":21151560,"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":["jackson","java","json","language","query","transform"],"created_at":"2024-08-01T05:01:03.412Z","updated_at":"2025-04-13T14:00:13.013Z","avatar_url":"https://github.com/schibsted.png","language":"Java","funding_links":[],"categories":["Java","language","Recently Updated","Projects","\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":["[Mar 26, 2025](/content/2025/03/26/README.md)","Data Mapping Solution"],"readme":"\n# JSLT\n\nJSLT is a complete query and transformation language for JSON.  The\nlanguage design is inspired by [jq](https://stedolan.github.io/jq/),\n[XPath](https://www.w3.org/TR/1999/REC-xpath-19991116/), and\n[XQuery](https://en.wikipedia.org/wiki/XQuery).\n\nJSLT can be used as:\n * a query language to extract values from JSON (`.foo.bar[0]`),\n * a filter/check language to test JSON objects (`starts-with(.foo.bar[0], \"http://\")`) ,\n * a transformation language to convert between JSON formats.\n\nAn example transform:\n\n```\n{\n    \"time\": round(parse-time(.published, \"yyyy-MM-dd'T'HH:mm:ssX\") * 1000),\n    \"device_manufacturer\": .device.manufacturer,\n    \"device_model\": .device.model,\n    \"language\": .device.acceptLanguage,\n    \"os_name\": .device.osType,\n    \"os_version\": .device.osVersion,\n    \"platform\": .device.platformType,\n    \"user_properties\": {\n        \"is_logged_in\" : boolean(.actor.\"spt:userId\")\n    }\n}\n```\n\n[**Demo playground**](http://www.garshol.priv.no/jslt-demo).\n\n[**Language tutorial**](tutorial.md).\n\n[**Function documentation**](functions.md).\n\n[**More examples**](examples/README.md).\n\n[**Javadoc**](http://javadoc.io/doc/com.schibsted.spt.data/jslt).\n\n[**API introduction**](docs/api.md).\n\n[![Build Status](https://travis-ci.org/schibsted/jslt.svg?branch=master)](https://travis-ci.org/schibsted/jslt)\n\n## Quick reference\n\n| Operation     | Explanation |\n| ------------- | ------------- |\n| `.`             | The context node  |\n| `.\u003cname\u003e`       | [Get value of key](tutorial.md#dot-accessors) `\"\u003cname\u003e\"` inside an object  |\n| `.[\u003cindex\u003e]`          | [Get value](tutorial.md#array-indexing) `\u003cindex\u003e` inside an array |\n| `.[\u003cfrom\u003e : \u003cto\u003e]`     | [Array slicing](tutorial.md#array-indexing) |\n| `if (\u003cexpr\u003e) \u003cexpr\u003e else \u003cexpr\u003e` | [If test](tutorial.md#if-expressions) to decide which value to return |\n| `let \u003cname\u003e = \u003cexpr\u003e` | [Define a variable](tutorial.md#variables) |\n| `$\u003cname\u003e`             | [Refer to a variable](tutorial.md#variables) |\n| `[for (\u003cexpr\u003e) \u003cexpr\u003e]` | [Transform an array](tutorial.md#for-expressions) |\n| `{for (\u003cexpr\u003e) \u003cexpr\u003e : \u003cexpr\u003e}` | [Transform an object](tutorial.md#object-for-expressions) |\n| `def \u003cname\u003e(\u003cname\u003e, \u003cname\u003e...) \u003cexpr\u003e` | [Declare a function](tutorial.md#function-declarations) |\n| `// \u003canything up to end of line\u003e` | Comment |\n| `{ \u003ckey\u003e : \u003cexpr\u003e }`               | [Object constructor](tutorial.md#json-construction) |\n| `{ \u003ckey\u003e : \u003cexpr\u003e, * : . }`        | Specify one key, [copy rest of input](tutorial.md#object-matching) |\n| `5 * 7 + 23.2`        | Arithmetic operations |\n| `7 \u003c 5`        | Comparators |\n| `7 \u003c 5 and .foo == \"yes\"` | Boolean operators |\n\n## Using the library\n\nTo include JSLT in your project, depend on:\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.schibsted.spt.data\u003c/groupId\u003e\n  \u003cartifactId\u003ejslt\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.14\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nAt runtime JSLT depends on Jackson, and nothing else.\n\nTo transform one `JsonNode` into another, do:\n\n```\nimport com.schibsted.spt.data.jslt.Parser;\nimport com.schibsted.spt.data.jslt.Expression;\n\nJsonNode input = ...;\nExpression jslt = Parser.compileString(transform);\nJsonNode output = jslt.apply(input);\n```\n\nFor more alternatives, see [the\njavadoc](http://javadoc.io/doc/com.schibsted.spt.data/jslt).\n\n## Command-line\n\nTo run transforms on the command-line, first build with `./gradlew\nclean shadowJar`. Then you can run with:\n\n```\njava -cp build/libs/*.jar com.schibsted.spt.data.jslt.cli.JSLT transform.jslt input.json\n```\n\nThe result is written to standard out.\n\n## Extension functions\n\nYou can implement your own functions and add them to the language.\nSee [the extension function tutorial](extensions.md).\n\n## Feedback\n\nIf you have questions about how to use JSLT, please ask the question\non StackOverflow, with the tag `jslt`.\n\nIf you have problems, feature requests, or think you found a bug,\nplease open an issue.\n\n## Status\n\nThe language design is not finished, so features may be added. The\nlanguage as it stands is not likely to change.\n\nThe entire language is implemented, and all of the function library.\nFunctions may be added.\n\nThe language has been used in production at Schibsted since January\n2018, performing about 9 billion transforms per day, and many times\nmore queries.\n\n## Building JSLT\n\nTo build JSLT as a jar file, run `./gradlew jar`.\n\nTo build a fat jar with all dependencies included, run `./gradlew\nshadowJar`.\n\nTo run the tests: `./gradlew check`.\n\nThere is a `pom.xml` file, but Maven is not used for building JSLT,\nand the file is not intended to work. It's only there to make Github\ndependency tracking work.\n\n## More information\n\nDeveloping a language for JSON processing: [video of\ntalk](https://vimeo.com/289470470), [slides\nonly](https://www.slideshare.net/larsga/jslt-json-querying-and-transformation).\n\n[Running the playground yourself](playground/README.md)\n\nAnthony Sparks is working on a\n[VM-based implementation in Java](https://github.com/tonysparks/jslt2)\n\n[A paper](https://arxiv.org/abs/1908.10754) describing (among other\nthings) some of the ways Schibsted uses JSLT.\n\n[Visual Studio syntax highlighter](https://marketplace.visualstudio.com/items?itemName=jarno-rajala.jslt-lang) for JSLT.\n\n[IntelliJ JSLT plugin](https://github.com/fuchsst/jslt-intellij-plugin).\n\n[Apache Camel JSLT component](https://camel.apache.org/components/latest/jslt-component.html).\n\nJSLT is also integrated in [Apache NiFi](https://nifi.apache.org/) [as a processor](https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-jslt-nar/1.20.0/org.apache.nifi.processors.jslt.JSLTTransformJSON/index.html).\n\n[How Willhaben.at uses JSLT with Kafka Connect](https://tech.willhaben.at/kafka-connect-custom-single-message-transform-using-jslt-2fc57ae98395)\n\n[IBM Cloud Pak for Business Automation](https://www.ibm.com/docs/en/cloud-paks/cp-biz-automation/21.0.x?topic=specification-event-selectors-transformers).\n\n[Pincette event sourcing framework uses JSLT](https://github.com/json-event-sourcing/pincette-jes).\n\n## LICENSE\n\nCopyright (c) 2018 Schibsted Marketplaces Products \u0026 Technology AS\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at `http://www.apache.org/licenses/LICENSE-2.0`\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n## What is missing\n\nThings to be done:\n  * Move the tests out into YAML files.\n  * Write a proper spec with EBNF and everything.\n  * Fix the syntax ambiguity problem with `let` and `def`.\n  * Implement toString() throughout the object tree, so that it's\n    possible to turn expressions back to strings.\n  * Optimizer:\n     * Optimize `... and boolean( ... )` by removing `boolean()`.\n     * Implement parse tree traversal API.\n     * Make sure entire tree is traversed (inside function decls and\n       variables, for example).\n     * Complete constant folding. Particularly constant folding for variables\n       would be valuable.\n     * Inlining of functions.\n     * Eliminate unused variables.\n  * Use property-based testing and fuzz testing to harden the parser.\n\nSee also [the list of ideas](ideas/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschibsted%2Fjslt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschibsted%2Fjslt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschibsted%2Fjslt/lists"}