私は次のようなオブジェクトをストリングしています{'foo': 'bar'}
文字列をオブジェクトに戻すにはどうすればよいですか?
ベストアンサー1
必要があるJSON.parse()
有効な JSON 文字列。
var str = '{"hello":"world"}';
try {
var obj = JSON.parse(str); // this is how you parse a string into JSON
document.body.innerHTML += obj.hello;
} catch (ex) {
console.error(ex);
}