我有一个对象使用JSON.stringify()转换为json字符串然后我需要使用相同的对象与JSON.parse(),但我得到数组值为空,如何获取原始数据,请帮助解决这个问题,在下面的代码中是stringify数据
{
"agefrom":18,
"ageto":60,
"heightfrom":"1",
"heightto":"28",
"steps":["Never","One"],
"number":["One","two "],
"education":["B.E","B.E / B.Tech"]
}
转换成JSON.parse之后的数据
{
"agefrom":18,
"ageto":60,
"heightfrom":"1",
"heightto":"28",
"steps":"",
"number":"",
"education":""
}
fiddle尝试这个小提琴。这对我来说可以。
a = {
"agefrom": 18,
"ageto": 60,
"heightfrom": "1",
"heightto": "28",
"steps": ["Never", "One"],
"number": ["One", "two "],
"education": ["B.E", "B.E / B.Tech"]
}
a = JSON.stringify(a)
document.write(a);
b = JSON.parse(a);
document.write(JSON.stringify(b))