{"id":37153639,"url":"https://github.com/georged19/json-logic-go","last_synced_at":"2026-01-14T18:02:43.730Z","repository":{"id":43659624,"uuid":"129214528","full_name":"GeorgeD19/json-logic-go","owner":"GeorgeD19","description":"Build complex rules, serialize them as JSON, and execute them in GO","archived":false,"fork":false,"pushed_at":"2022-02-25T11:16:52.000Z","size":2189,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-21T10:52:53.963Z","etag":null,"topics":["go","golang","json","jsonlogic","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","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/GeorgeD19.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-12T07:56:55.000Z","updated_at":"2025-04-22T12:00:11.000Z","dependencies_parsed_at":"2022-08-28T20:20:43.624Z","dependency_job_id":null,"html_url":"https://github.com/GeorgeD19/json-logic-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GeorgeD19/json-logic-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeD19%2Fjson-logic-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeD19%2Fjson-logic-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeD19%2Fjson-logic-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeD19%2Fjson-logic-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeorgeD19","download_url":"https://codeload.github.com/GeorgeD19/json-logic-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeD19%2Fjson-logic-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28429383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","golang","json","jsonlogic","parser"],"created_at":"2026-01-14T18:02:43.190Z","updated_at":"2026-01-14T18:02:43.724Z","avatar_url":"https://github.com/GeorgeD19.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-logic-go\n\nThis parser accepts [JsonLogic](http://jsonlogic.com) rules and executes them in Go.\n\nThe JsonLogic format is designed to allow you to share rules (logic) between front-end and back-end code (regardless of language difference), even to store logic along with a record in a database.  JsonLogic is documented extensively at [JsonLogic.com](http://jsonlogic.com), including examples of every [supported operation](http://jsonlogic.com/operations.html) and a place to [try out rules in your browser](http://jsonlogic.com/play.html).\n\nThe same format can be executed in the following libraries:\n- JavaScript [json-logic-js](https://github.com/jwadhams/json-logic-js/)\n- PHP [json-logic-php](https://github.com/jwadhams/json-logic-php/)\n- Python [json-logic-py](https://github.com/nadirizr/json-logic-py)\n- Ruby [json-logic-ruby](https://github.com/bhgames/json-logic-ruby)\n- Go [json-logic-go](https://github.com/GeorgeD19/json-logic-go)\n\n## Examples\n\n### A note about types\n\nThis is a GO interpreter of a format designed to be transmitted and stored as JSON.  So it makes sense to conceptualize the rules in JSON.\n\nExpressed in JSON, a JsonLogic rule is always one key, with an array of values.\n\n```GO\nrule := `{\"==\":[\"apples\", \"apples\"]}`\nresult, err := jsonlogic.Run(rule)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// true\n```\n\n### Simple\n```GO\nrule := `{\"==\":[1, 1]}`\nresult, err := jsonlogic.Run(rule)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// true\n```\n\nThis is a simple test, equivalent to `1 == 1`.  A few things about the format:\n\n  1. The operator is always in the \"key\" position. There is only one key per JsonLogic rule.\n  2. The values are typically an array.\n  3. Each value can be a string, number, boolean, array, or null\n\n### Compound\nHere we're beginning to nest rules. \n\n```GO\nrule := `{\"and\": [\n\t\t{ \"\u003e\": [3,1] },\n\t\t{ \"\u003c\": [1,3] }\n\t] }`\nresult, err := jsonlogic.Run(rule)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// true\n```\n    \n### Data-Driven\n\nObviously these rules aren't very interesting if they can only take static literal data. Typically `jsonlogic.Apply` will be called with a rule object and a data object however you can also use `jsonlogic.Run` to run a rule object without a data object. You can use the `var` operator to get attributes of the data object:\n\n```GO\nrule := `{ \"var\": [\"a\"] }`\ndata := `{ \"a\": 1, \"b\": 2 }`\nresult, err := jsonlogic.Apply(rule, data)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// 1\n```\n\nIf you like, we support [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar) on unary operators to skip the array around values:\n\nYou can also use the `var` operator to access an array by numeric index:\n\n```GO\nrule := `{ \"var\": 1 }`\ndata := `[ \"apple\", \"banana\", \"carrot\" ]`\nresult, err := jsonlogic.Apply(rule, data)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// \"banana\"\n```\n\nHere's a complex rule that mixes literals and data. The pie isn't ready to eat unless it's cooler than 110 degrees, *and* filled with apples.\n\n```GO\nrule := `{ \"and\": [\n\t{ \"\u003c\": [ { \"var\": \"temp\" }, 110 ] },\n\t{ \"==\": [ { \"var\": \"pie.filling\" }, \"apple\" ] }\n] }`\ndata := `{ \"temp\": 100, \"pie\": { \"filling\": \"apple\" } }`\nresult, err := jsonlogic.Apply(rule, data)\nif err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(result)\n// true\n```\n    \n## Installation\n\n```\ngo get github.com/GeorgeD19/json-logic-go\n```\n\nIf that doesn't suit you, and you want to manage updates yourself, the entire library is self-contained in jsonlogic.go and you can download it straight into your project as you see fit.\n\n```\ncurl -O https://raw.githubusercontent.com/GeorgeD19/json-logic-go/master/jsonlogic.go\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorged19%2Fjson-logic-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorged19%2Fjson-logic-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorged19%2Fjson-logic-go/lists"}