This namespace defines middleware methods for parsing JSON strings. Please see Ziggurat Middleware for more details.
This namespace defines middleware methods for parsing JSON strings. Please see [Ziggurat Middleware](https://github.com/gojek/ziggurat#middleware-in-ziggurat) for more details.
(parse-json handler-fn topic-entity)(parse-json handler-fn topic-entity key-fn)This method returns a function which deserializes the provided message before processing it.
It uses deserialize-json defined in this namespace to parse JSON strings.
Takes following arguments:
handler-fn : A function which would process the parsed JSON string
topic-entity : Stream route topic entity (as defined in config.edn). It is only used for publishing metrics.
key-fn : key-fn can be either true, false of a generic function to transform keys in JSON string.
If true, would coerce keys to keywords, and if false it would leave keys as strings.
Default value is true.
An Example
For parsing a JSON string "{"foo":"bar"}" to {"foo":"bar"}, call the function with key-fn false
(parse-json (fn [message] ()) "topic" false)
For parsing a JSON string "{"foo":"bar"}" to {:foo:"bar"}, call the function without passing key-fn,
whose default value is true.
(parse-json (fn [message] ()) "topic")
This method returns a function which deserializes the provided message before processing it.
It uses `deserialize-json` defined in this namespace to parse JSON strings.
Takes following arguments:
`handler-fn` : A function which would process the parsed JSON string
`topic-entity` : Stream route topic entity (as defined in config.edn). It is only used for publishing metrics.
`key-fn` : key-fn can be either true, false of a generic function to transform keys in JSON string.
If `true`, would coerce keys to keywords, and if `false` it would leave keys as strings.
Default value is true.
An Example
For parsing a JSON string `"{"foo":"bar"}"` to `{"foo":"bar"}`, call the function with `key-fn` false
`(parse-json (fn [message] ()) "topic" false)`
For parsing a JSON string `"{"foo":"bar"}"` to `{:foo:"bar"}`, call the function without passing `key-fn`,
whose default value is true.
`(parse-json (fn [message] ()) "topic")`
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |