mardi 4 août 2015

how can I convert a string to JSON in Ruby

I have read the data online but it is in a string format. I've also researched online but the few examples I checked returned string format too. How can i make it so that it returns a JSON object.

assuming the result of reading the data was

text = '{"one":1,"two":2}'

then i used:

data = JSON.parse(text).to_json 

but when i do

puts data.class

the result is still a string



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire