Closed jackcarrozzo closed 9 years ago
Ah, after reading [https://github.com/fukamachi/caveman/issues/22](issue #22), I found that simply doing (obj-name (getjso :|name| first-obj))
works (ie, the key name in pipes) (also added st-json to imported symbols). Why is the key different from the REPL despite the object looking exactly the same?
Because JSON keys are case sensitive and it is lower-cased "name". If you wanna access with :name
(without vertical bars), send an HTTP request like this:
curl -XPOST localhost:8080/post-test/1 -H "Content-type: application/json" -d '{"myobjlist":[{"NAME":"me","v":8},{"NAME":"you","v":9}]}'
Ahh got it, thanks!
On Mar 20, 2015, at 4:41 AM, Eitaro Fukamachi notifications@github.com wrote:
Because JSON keys are case sensitive and it is lower-cased "name". If you wanna access with :name (without vertical bars), send an HTTP request like this:
curl -XPOST localhost:8080/post-test/1 -H "Content-type: application/json" -d '{"myobjlist":[{"NAME":"me","v":8},{"NAME":"you","v":9}]}' — Reply to this email directly or view it on GitHub.
What's the correct way to parse pieces out of a POSTed body that arrived with
application/json
? I have this route:Which I call like this:
That produces this response:
The name field returns NIL, as if the key was not found. However, doing the same thing in the REPL produces the expected action:
What's the difference with
getjso
/ what am I doing wrong?