{"id":19858640,"url":"https://github.com/nytimes/jsonlogic","last_synced_at":"2025-09-10T05:13:12.612Z","repository":{"id":62431909,"uuid":"450217530","full_name":"nytimes/jsonlogic","owner":"nytimes","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-07T18:51:39.000Z","size":35,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-19T20:06:24.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nytimes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2022-01-20T18:43:49.000Z","updated_at":"2024-10-06T15:14:56.000Z","dependencies_parsed_at":"2022-11-01T21:00:56.326Z","dependency_job_id":null,"html_url":"https://github.com/nytimes/jsonlogic","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/nytimes/jsonlogic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nytimes%2Fjsonlogic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nytimes%2Fjsonlogic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nytimes%2Fjsonlogic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nytimes%2Fjsonlogic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nytimes","download_url":"https://codeload.github.com/nytimes/jsonlogic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nytimes%2Fjsonlogic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274416363,"owners_count":25280939,"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","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-12T14:24:12.235Z","updated_at":"2025-09-10T05:13:12.587Z","avatar_url":"https://github.com/nytimes.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# JsonLogic\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.nytimes/jsonlogic.svg)](https://clojars.org/com.nytimes/jsonlogic)\n[![Build Status](https://cloud.drone.io/api/badges/nytimes/jsonlogic/status.svg?ref=refs/heads/main)](https://cloud.drone.io/nytimes/jsonlogic)\n\nA [jsonlogic][1] implementation for Clojure.\n\n## Installation\n\n```clojure\n[com.nytimes/jsonlogic \"1.0.0\"]\n```\n\n## Usage\n\n```clojure\n(require '[com.nytimes.jsonlogic :as jsonlogic])\n\n(jsonlogic/apply {:if [true \"Foo\" \"Bar\"]})\n\"Foo\"\n```\n\nThis library supports encoding the operators as keywords, string, or symbols.\nAll of these values are coerced to symbols for evalution..\n\n```clojure\n(jsonlogic/apply {\"+\" [1 2]})\n;;=\u003e 3\n(jsonlogic/apply {:+ [1 2]})\n;;=\u003e 3\n(jsonlogic/apply {'+ [1 2]})\n;;=\u003e 3\n```\n\n## Extending JsonLogic\n\nYou can add custom JsonLogic operations by extending the `operate` multi-method.\n\n### Arguments\n\nOperate receives two arguments, a map of the operation and the data provided to\napply. For example, given this invocation:\n\n```clojure\n(jsonlogic/apply {\"*\" [{\"var\" \"x\"} {\"var\" \"x\"}]}\n                 {\"x\" 2})\n```\n\nThe arguments to `*` are:\n\n1. `{* [{var \"x\"} {var \"x\"}]}`\n2. `{\"x\" 2}`\n\n### A Custom Operator Example\n\nHere is an example of adding a custom power function.\n\n```clojure\n(require '[com.nytimes.jsonlogic :as json])\n(require '[clojure.math :as math])\n\n(defmethod jsonlogic/operate '**\n  [{args '**} _env]\n  (if (not= 2 (count args))\n    (throw (ex-info \"** requires exactly two arguments\" {:args args}))\n    (let [[base exponent] args]\n      (math/pow base exponent))))\n\n(jsonlogic/apply {'** [2 3]})\n;;=\u003e 8.0\n```\n\n[1]: https://jsonlogic.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnytimes%2Fjsonlogic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnytimes%2Fjsonlogic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnytimes%2Fjsonlogic/lists"}