既然你提到response.body
是一個字符串,你可以做JSON.parse(response.body)
。你不需要插入它。
根據您的評論給的例子,它工作正常:
2.1.2-perf :007 > s = '{ "age_result": [ { "column_id": [ "B01001003", "B01001027" ], "name": "Under 5 years", "number": [ 6774.0, 6416.0 ] }, { "column_id": [ "B01001004", "B01001028" ], "name": "5 to 9 years", "number": [ 5981.0, 6470.0 ] }] }'
=> "{ \"age_result\": [ { \"column_id\": [ \"B01001003\", \"B01001027\" ], \"name\": \"Under 5 years\", \"number\": [ 6774.0, 6416.0 ] }, { \"column_id\": [ \"B01001004\", \"B01001028\" ], \"name\": \"5 to 9 years\", \"number\": [ 5981.0, 6470.0 ] }] }"
2.1.2-perf :008 > JSON.parse(s)
=> {"age_result"=>[{"column_id"=>["B01001003", "B01001027"], "name"=>"Under 5 years", "number"=>[6774.0, 6416.0]}, {"column_id"=>["B01001004", "B01001028"], "name"=>"5 to 9 years", "number"=>[5981.0, 6470.0]}]}
什麼是你的問題? – sawa
如何解決它以使解析工作? –
你可以顯示什麼'response.body'看起來像? – Atri