Use JSON object returned from a URL in rails Use JSON object returned from a URL in rails json json

Use JSON object returned from a URL in rails


JSON support in Ruby on Rails is provided by the ActiveSupport::JSON, but it wraps JSON gem behind the scene. So you can opt your choice.

Check this example,

@data = [{"id":"7354857336","owner":"49091484@N07","secret":"dc7ce98bf9","server":"8151","farm":9,"title":"01_resize","ispublic":1,"isfriend":0,"isfamily":0},{"id":"7355453164","owner":"41440187@N07","secret":"b0bc716ee6","server":"7225","farm":8,"title":"{Laduree Macaroons} explore #2","ispublic":1,"isfriend":0,"isfamily":0},{"id":"7355183126","owner":"38937613@N03","secret":"c342e37a57","server":"7232","farm":8,"title":"REFLECTED AT MIDNIGHT [EXPLORED]","ispublic":1,"isfriend":0,"isfamily":0}]

In .erb file

<% @data.each  do |photo| %> <%= photo.id%> ---<%= photo.title %><br></br><% end %>