{"id":13788427,"url":"https://github.com/ring-clojure/ring-json","last_synced_at":"2025-04-08T10:20:25.476Z","repository":{"id":3972285,"uuid":"5067049","full_name":"ring-clojure/ring-json","owner":"ring-clojure","description":"Ring middleware for handling JSON","archived":false,"fork":false,"pushed_at":"2021-06-09T19:33:32.000Z","size":65,"stargazers_count":318,"open_issues_count":12,"forks_count":47,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-31T17:15:05.458Z","etag":null,"topics":["clojure","json","middleware","ring"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","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/ring-clojure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-16T12:23:39.000Z","updated_at":"2025-03-13T14:46:32.000Z","dependencies_parsed_at":"2022-07-13T01:50:36.998Z","dependency_job_id":null,"html_url":"https://github.com/ring-clojure/ring-json","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ring-clojure%2Fring-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ring-clojure%2Fring-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ring-clojure%2Fring-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ring-clojure%2Fring-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ring-clojure","download_url":"https://codeload.github.com/ring-clojure/ring-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266568,"owners_count":20910837,"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":["clojure","json","middleware","ring"],"created_at":"2024-08-03T21:00:45.887Z","updated_at":"2025-04-08T10:20:25.451Z","avatar_url":"https://github.com/ring-clojure.png","language":"Clojure","readme":"# Ring-JSON\n\n[![Build Status](https://travis-ci.org/ring-clojure/ring-json.svg?branch=master)](https://travis-ci.org/ring-clojure/ring-json)\n\nStandard Ring middleware functions for handling JSON requests and\nresponses.\n\n## Installation\n\nTo install, add the following to your project `:dependencies`:\n\n    [ring/ring-json \"0.5.1\"]\n\n\n## Usage\n\n#### wrap-json-response\n\nThe `wrap-json-response` middleware will convert any response with a\ncollection as a body (e.g. map, vector, set, seq, etc) into JSON:\n\n```clojure\n(require '[ring.middleware.json :refer [wrap-json-response]]\n         '[ring.util.response :refer [response]])\n\n(defn handler [request]\n  (response {:foo \"bar\"}))\n\n(def app\n  (wrap-json-response handler))\n```\n\n\n#### wrap-json-body\n\nThe `wrap-json-body` middleware will parse the body of any request\nwith a JSON content-type into a Clojure data structure, and assign it\nto the `:body` key.\n\nThis is the preferred way of handling JSON requests.\n\n```clojure\n(use '[ring.middleware.json :only [wrap-json-body]]\n     '[ring.util.response :only [response]])\n\n(defn handler [request]\n  (prn (get-in request [:body \"user\"]))\n  (response \"Uploaded user.\"))\n\n(def app\n  (wrap-json-body handler {:keywords? true :bigdecimals? true}))\n```\n\n\n#### wrap-json-params\n\nThe `wrap-json-params` middleware is an alternative to\n`wrap-json-body` for when it's convenient to treat a JSON request as a\nmap of parameters. Rather than replace the `:body` key, the parsed\ndata structure will be assigned to the `:json-params`. The parameters\nwill also be merged into the standard `:params` map.\n\n```clojure\n(require '[ring.middleware.json :refer [wrap-json-params]]\n         '[ring.util.response :refer [response]])\n\n(defn handler [request]\n  (prn (get-in request [:params \"user\"]))\n  (response \"Uploaded user.\"))\n\n(def app\n  (wrap-json-params handler))\n```\n\nNote that Ring parameter maps use strings for keys. For consistency,\nthis means that `wrap-json-params` does not have a `:keywords?`\noption. Instead, use the standard Ring `wrap-keyword-params` function:\n\n```clojure\n(require '[ring.middleware.keyword-params :refer [wrap-keyword-params]])\n\n(def app\n  (-\u003e handler\n      wrap-keyword-params\n      wrap-json-params))\n```\n\n\n## License\n\nCopyright © 2021 James Reeves\n\nDistributed under the MIT License, the same as Ring.\n","funding_links":[],"categories":["server"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fring-clojure%2Fring-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fring-clojure%2Fring-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fring-clojure%2Fring-json/lists"}