need help on json format extraction multiple deep

62 views
Skip to first unread message

dinesh bhardwaj

unread,
Sep 6, 2017, 7:23:48 AM9/6/17
to Clojure
I have a json request coming as: 

Headers:
//user defined headers
Content-type: application/json

POST body
:

{
   
"lang": "en",
   
"result": {
       
"parameters": {
           
"city": "Rome",
           
"name": "Tom"
       
},
       
"contexts": [],
       
"resolvedQuery": "my name is Tom", 
     }, 
       
"action": "greetings",
   
},
}

    I am ble to extract like :lang using following
(get-in (json-body-request request {:keywords? true :bigdecimals true}) [:body :lang])
But I am not able to extract :resolvedQuerry. Although I am able to extract :result. I used following code , but I know i am missing something. Please help me out?  
(get  (get-in (json-body-request request {:keywords? true :bigdecimals true}) [:body :result]) :resolvedQuerry))

Andy Fingerhut

unread,
Sep 6, 2017, 7:36:46 AM9/6/17
to clo...@googlegroups.com
I don't know if this is the issue, but the JSON data has it spelled resolvedQuery, but you spelled it differently in your Clojure code as :resolvedQuerry  (two "r"s in Query instead of one)

In general, using a REPL session to examine the contents of data, or good old-fashioned debug print statements or logging, to print out the contents of intermediate values like from your expression (get-in (json-body-request request {:keywords? true :bigdecimals true}) [:body :result]) :resolvedQuerry), can help debug these kinds of things.

Andy

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dinesh bhardwaj

unread,
Sep 6, 2017, 9:40:43 AM9/6/17
to Clojure
Thanks Andy.

I love you man :) . I am new to start a project in clojure. Thanks for the help. Now, I need not go to Node.js. 

Regards
Dinesh


For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages