Created
May 6, 2015 02:01
-
-
Save henriqueutsch/fd0e1b55680411f70e7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
my_hash = JSON.parse('{"hello": "goodbye"}') | |
puts my_hash.class => Hash | |
puts my_hash["hello"] => goodbye |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p teste = '{"result":[]}{"result":[{"alternative":[{"transcript":"abrir chrome","confidence":0.92921507},{"transcript":"abrir o chrome"}],"final":true}],"result_index":0}' | |
p teste.encoding | |
puts teste | |
puts resposta = JSON.parse(teste) | |
puts resposta.class => string | |
puts resposta = JSON.parse([ teste ].to_json).first | |
puts resposta.class => string | |
puts resposta = JSON.parse(teste.to_json).first | |
puts resposta.class => string | |
/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/json/common.rb:155:in `parse': 757: unexpected token at '{"result":[{"alternative":[{"transcript":"abrir chrome","confidence":0.92921507},{"transcript":"abrir o chrome"}],"final":true}],"result_index":0}' (JSON::ParserError) | |
from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/json/common.rb:155:in `parse' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Falta uma virgula para separar os objetos do JSON.
[{"result"=>[]},
{"result"=>[{"alternative"=>[{"transcript"=>"abrir chrome", "confidence"=>0.92921507}, {"transcript"=>"abrir o chrome"}], "final"=>true}], "result_index"=>0}]