Ruby JSON Problem

Hello,

I’am new to Ruby and JSON, and having some trouble with it. I try to get
JSON Objects from the Toodledo API 2.0. They say they are working with
JSON objects, but I guess they are using Arrays as well, now I dont know
how to get the elemnts or objects inside the Array, I can use
“pretty_generate”, but not json[ “id” ] to just get the id of the task.
My goal is, to get the elements and beeing able to format them, to use
them in haml and make it look good.

first attempt:

 get '/save' do

response = RestClient.get
http://api.toodledo.com/2/tasks/get.php?key=da21e24e2a00ba9d45008974aed00***;modafter=1234567890;fields=folder,star,priority’,
{:accept => :json}
test = JSON.parse(response)
test.to_json
blub = JSON.pretty_generate(test)
test1 = blub[1…-2]
puts test1

Someone told me “RestClient.get” isn’t very practial, so I tried :

get ‘/test’ do
res =
Net::HTTP.get_response(URI(‘http://api.toodledo.com/2/tasks/get.php?key=da21e24e2a00ba9d45008974aed00***;modafter=1234567890;fields=folder,star,priorityl’))
p res.body

but can only output one Character.

This is the JSON Data i get from toodledo:
[{“num”:“4”,“total”:“4”},{“id”:“11980343”,“title”:“Add some items to
your todo
list”,“modified”:1391670256,“completed”:0,“folder”:“0”,“priority”:“2”,“star”:“0”},{“id”:“11980345”,“title”:“Visit
the Settings section and configure your
account”,“modified”:1391670256,“completed”:0,“folder”:“0”,“priority”:“1”,“star”:“0”},{“id”:“11980347”,“title”:“Watch
our tutorial videos in the Help
section”,“modified”:1391670256,“completed”:0,“folder”:“0”,“priority”:“3”,“star”:“1”},{“id”:“12607789”,“title”:“test”,“modified”:1392285802,“completed”:0,“folder”:“0”,“priority”:“0”,“star”:“0”}]

I’am desperate for help now :smiley:

Thank you in advance

Benny