{"id":27958987,"url":"https://github.com/yxuco/gojsonata","last_synced_at":"2026-04-30T13:31:46.772Z","repository":{"id":57514646,"uuid":"168462668","full_name":"yxuco/gojsonata","owner":"yxuco","description":"Execute JSONata query and transformation expressions in Golang","archived":false,"fork":false,"pushed_at":"2019-02-06T21:55:59.000Z","size":2823,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T04:11:51.903Z","etag":null,"topics":["go","json-transformation","jsonata","otto"],"latest_commit_sha":null,"homepage":null,"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/yxuco.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}},"created_at":"2019-01-31T04:26:42.000Z","updated_at":"2020-09-13T17:23:13.000Z","dependencies_parsed_at":"2022-09-06T03:02:46.171Z","dependency_job_id":null,"html_url":"https://github.com/yxuco/gojsonata","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yxuco/gojsonata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxuco%2Fgojsonata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxuco%2Fgojsonata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxuco%2Fgojsonata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxuco%2Fgojsonata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yxuco","download_url":"https://codeload.github.com/yxuco/gojsonata/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxuco%2Fgojsonata/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32466333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"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","json-transformation","jsonata","otto"],"created_at":"2025-05-07T18:27:18.164Z","updated_at":"2026-04-30T13:31:46.754Z","avatar_url":"https://github.com/yxuco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gojsonata\nExecute JSONata query and transformation expressions in Golang.\n\n## Problem Statement\nWe want a generic solution for transfomation of structured data in Golang.  [XSLT](https://www.w3.org/TR/xslt-30/) is the most advanced solution for transforming XML data, but it is not well supported by Golang.  [JSONata](http://jsonata.org/) is an elegant solution for transforming JSON data, but it supports only JavaScripts.\n\nThis project describes how to execute JSONata transformation expressions in Golang.  Following are the tools used to make it work.\n* [otto](https://github.com/robertkrimen/otto) - A JavaScript interpreter in Go.  It supports only ES5 syntax.\n* [JSONata](https://github.com/jsonata-js/jsonata) - query and transformation language for JSON.\n* [traceur](https://github.com/google/traceur-compiler) - JavaScript transpiler for generating ES5 code from ES6+ code.\n* [go-bindata](https://github.com/jteeuwen/go-bindata) - Go utility for converting any file into Golang source code.\n\nWe provide scripts to transpile JSONata library to ES5, and then convert the resulting files into Golang source code.\n\nWe then implement a Golang utility that you can use to transform any JSON data using JSONata expression.  This utility creates an otto JavaScript interpreter, and preloads JSONata libraries when the utility is loaded.  Thus, any complex data transformation request can be handled by a simple function call with input JSON data and an JSONata expression.\n\n## Installation\nInstall [Go version 1.11.x](https://golang.org/doc/install) and [set GOPATH environment variable](https://golang.org/doc/code.html#GOPATH).\n\nInstall [GNU make](https://www.gnu.org/software/make/). For ubuntu, e.g., use the following commands\n```\nsudo apt update\nsudo apt install make\nsudo apt install make-guile\n```\n\nInstall [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/).  For ubuntu, e.g., use the following command\n```\nsudo apt install nodejs npm\n```\n\nClone this project, then setup and test it as follows:\n```\nexport PATH=${GOPATH}/bin:${PATH}\ngo get -u -d github.com/yxuco/gojsonata\ncd ${GOPATH}/src/github.com/yxuco/gojsonata\nmake\n```\n\n## Examples\n\nFollowing Golang example shows the execution of a JSONata expression [vehicle-expr.txt](https://github.com/yxuco/gojsonata/tree/master/tests/vehicle-expr.txt) on the input data [vehicle.json](https://github.com/yxuco/gojsonata/tree/master/tests/vehicle.json), which created an output [result](https://github.com/yxuco/gojsonata/tree/master/tests/result-pretty.json) of different schema.\n```\n\tdata, _ := ioutil.ReadFile(\"./tests/vehicle.json\")\n\texpr, _ := ioutil.ReadFile(\"./tests/vehicle-expr.txt\")\n\tresult, _ := Transform(string(data), string(expr))\n\tfmt.Printf(\"result value: %s\\n\", result)\n```\n\nA simpler transformation can also be done as follows:\n```\n\tvalue, _ := RunScript(\n\t\t`var data = {\n\t\t  example: [\n\t\t    {value: 4},\n\t\t    {value: 7},\n\t\t    {value: 13}\n\t\t  ]\n\t    };\n\t  \n\t    var expression = jsonata('$sum(example.value)');\n\t    expression.evaluate(data);`)\n\tresult, _ := value.ToInteger()  // result = 24\n```\n\nThe file [jsengine_test.go](https://github.com/yxuco/gojsonata/blob/master/jsengine_test.go) shows more Golang examples.\n\nYou may also use the [motto](https://github.com/ddliu/motto) command-line tool to test JSONata transformations, which is demonstrated by the following commands in the [Makefile](https://github.com/yxuco/gojsonata/blob/master/Makefile).\n```\n    make motto\n```\n\nFor quick interactive testing of JSONata scripts, you can use http://try.jsonata.org/ to edit JSON data and JSONata scripts, and view the results immediately. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyxuco%2Fgojsonata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyxuco%2Fgojsonata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyxuco%2Fgojsonata/lists"}