0

I have text with javascript code like this:

var data = {"name": "lorem ipsum", "brand": "ipsum", "attr": { "sizes": [{"name": "big", "value": "1"}, {"name": "small", "value": "2"}], "height":[{"name": "large", "value": "1"}], "url": "http://...", "desc": "lorem ipsum"}

How can I read it as json or some ruby object? I need import these datas to db. This text is return of API, which I get with Ruby(RoR) code.

quatermain
  • 1,442
  • 2
  • 18
  • 33
  • 1
    Does [this answer](http://stackoverflow.com/a/5410713/326543) help? – Srikanth Venugopalan Mar 25 '13 at 10:36
  • 1
    You might want to investigate Ruby's JSON module: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/json/rdoc/JSON.html Just be careful what options you use: parsing untrusted input has led to severe security issues. – Qsario Mar 25 '13 at 12:01
  • Thank you, I deleted "var data = " and then I parsed with json, thank you – quatermain Mar 29 '13 at 14:25

0 Answers0