【发布时间】:2016-06-02 18:29:09
【问题描述】:
我正在映射我的数组(有很多)。所以我们的想法是对数组中的所有对象/所有内容进行字符串化。
const studentInfoObj = students.map(value => (
// for each student return json string of the objects
// how can I just stringify everything within the array?
// but not the array itself. Just all the objects inside?
return JSON.stringify(???);
));
这是目前的json
{"Michael00043":
// stringify from this point
[
{"student_num":"20293290000HJ93",
"campus":"McHale",
"major":"PSI"
},
],
... more objects
[
{"medical_doc":"st.laurance hos",
"emergency_contact":"Adam Harley",
"blood_type":"O"
},
{"hospital":"st.laurance hos",
"ward":"B",
},
]
...
【问题讨论】:
-
您的解决方案是正确的。你想要什么?
-
您的 JSON 格式错误。你能举一个有效的例子吗?你有一个开始
[,但没有结束]。 -
@IMTheNachoMan 是的,很抱歉,它确实是。它非常长。我只是尝试发布一个简单的示例。
-
@risabhdev 好吧,我只是想弄清楚要字符串化的内容。如果我返回 JSON.stringify(value);它只是打印出“Michael00043”.. 但我正在尝试将 Michael00043/student 中的所有内容字符串化
标签: javascript reactjs