Answer the question
In order to leave comments, you need to log in
How to parse such json in Ruby?
Hello everyone, I need to parse json from one service, everything seems to work out, but json itself has one feeds key, it has data in brackets, I can’t get into it. Basically it contains json in itself. It turns out nested chtoli.
This is what feeds contains
[{"created_at"=>"2016-04-23T07:51:23Z", "entry_id"=
>131861, "field7"=>"20.5field3=15.1", "field4"=>"75
3.57 ", "field3"=>nil}, {"created_at"=>"2016-04-23T0
7:52:23Z", "entry_id"=>131862, "field7"=>"20.5field
3=15.2", " field4"=>"753.60", "field3"=>nil}]
And here is the json https://api.thingspeak.
Answer the question
In order to leave comments, you need to log in
Elementary:
require 'json'
res = JSON.parse(json_string)
res['feeds']
#[
# [0] {
# "created_at" => "2016-04-28T06:17:20Z",
# "entry_id" => 139303,
# "field3" => "13.1",
# "field4" => "753.73"
# },
# [1] {
# "created_at" => "2016-04-28T06:18:20Z",
# "entry_id" => 139304,
# "field3" => "13.1",
# "field4" => "753.72"
# }
#]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question