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
that is how JVM lambdas work if you want to parse request yourself
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.
Interesting approach, thank you. I guess what I really need is clj version of js->clj :keywordize-keys true
Great, ty, will give it try