Thank you so much Marc!! It works perfect! :)
El jueves, 21 de enero de 2016, 16:36:31 (UTC+1), Marc O'Morain escribió:
>
> The `get-in` function will help you:
>
>
> user=> (def result {:results [{:series [{:name "solr.numPedidos5",
> :columns ["time" "last"], :values [["1970-01-01T00:00:00Z" 0]]}]}]})
> #'user/result
>
> user=> (get-in result [:results 0 :series 0 :values 0 1])
> 0
>
>
> On 21 January 2016 at 15:29, Alex Latorre <[email protected]
> <javascript:>> wrote:
>
>> Hi all,
>>
>> I'm trying to get a value from a JSON. I query an influxdb database and I
>> get the next reply:
>>
>> {:orig-content-encoding gzip, :trace-redirects
>> [http://****/query?pretty=true;db=riemann;q=select%20last(value)%20from%20%22solr.numPedidos5%22%20where%20idTag%20=%20%27ADE99003392%27],
>>
>> :request-time 4, :status 200, :headers {Connection close, Content-Length
>> 165, Date Thu, 21 Jan 2016 15:24:24 GMT, X-Influxdb-Version 0.9.2,
>> Request-Id 0db6c40f-c053-11e5-909c-000000000000, Content-Type
>> application/json}, :body {
>> "results": [
>> {
>> "series": [
>> {
>> "name": "solr.numPedidos5",
>> "columns": [
>> "time",
>> "last"
>> ],
>> "values": [
>> [
>> "1970-01-01T00:00:00Z",
>> 0
>> ]
>> ]
>> }
>> ]
>> }
>> ]
>> }}
>>
>> I get the JSON with (:body):
>>
>> {
>> "results": [
>> {
>> "series": [
>> {
>> "name": "solr.numPedidos5",
>> "columns": [
>> "time",
>> "last"
>> ],
>> "values": [
>> [
>> "1970-01-01T00:00:00Z",
>> 0
>> ]
>> ]
>> }
>> ]
>> }
>> ]
>> }
>>
>> I parse it with cheshire with (json/parse-string ... true):
>>
>> {:results [{:series [{:name solr.numPedidos5, :columns [time last],
>> :values [[1970-01-01T00:00:00Z 0]]}]}]}
>>
>> Now with (:results ...) I get:
>>
>> [{:series [{:name solr.numPedidos5, :columns [time last], :values
>> [[1970-01-01T00:00:00Z 0]]}]}]
>>
>> but now I don't know how to extract more values. I want to get the number
>> "0" from :values and I don't know how to get it.
>>
>> I would be very grateful if someone can help me with it.
>>
>> Thank you so much!
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.