This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-18
Channels
- # announcements (2)
- # aws-lambda (14)
- # babashka (4)
- # beginners (66)
- # clojure (113)
- # clojure-spec (9)
- # clojure-uk (7)
- # clojurescript (24)
- # data-science (12)
- # datomic (45)
- # docker (2)
- # emacs (1)
- # fulcro (48)
- # jobs-discuss (22)
- # kaocha (7)
- # keechma (3)
- # luminus (7)
- # off-topic (7)
- # re-frame (6)
- # shadow-cljs (43)
- # spacemacs (18)
- # tools-deps (2)
- # vim (1)
- # vscode (2)
- # yada (11)
If you use something other than InputStream/OutputStream as parameters to function, lambda will try to convert JSON to java classes.
Most likely you’ll want to read input from a InputStream, and then parse it as JSON or END. If you go via lambda’s automatic JSON parsing, you’ll get java classes.
Thanks @jsyrjala I’ll try it
@jsyrjala why in your template you state to AWS that you are receiving 2 parameters
[InputStream OutputStream]
And that you return void
I thought I’d receive only one parameter, the InputStream
and my output would be a OutputStream
Hi. How can I quickly parse the input parameters in the handler function? It does not seem to a map I can destructure with keywords
(defn -handler
[this input context] ... )
parse input with e.g https://github.com/dakrone/cheshire
thanks. when I print the input params it's {operation=echo, message=Hello world!}
When I query its type it's java.util.LinkedHashMap. Doesn't look like json : )
here built in jvm lambda framework has parsed incoming json to a Java LinkedHashMap object before calling your handler function.
basically you can either use parameters [InputStream OutputStream]
and handle JSON -> clojure datastructure parsing and clojure -> JSON response generation your self. Or use automatic conversion from JSON to Java classes and back to JSON. I have preferred the former.