Parse remote JSON with ruby -


i have problem when try , parse remote json.

require 'net/http' require 'json'  url = "www.example.com" resp = net::http.get_response(uri.parse(url)) buffer = resp.body result = json.parse(buffer)  details = result['detail']  details.each |detail|   puts "latitude: #{detail['latitude']}" end 

the json returned it's this.

{detail:{id:578155,latitude:69.83}} 

any suggestion please ?

it's not valid json, use split , gsub methods parse it.

string = string.split("}") string = string[0].gsub("[", "") string = string[0].gsub("]", "") string = string.split(",") 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -