后端同事说前端切图仔你给我传个json回来,我说好的没问题。啪地一下,很快啊,我就把json传过去了(传的是json字符串)。原数据对象如下:
let obj = {
member: [
{id: 1, userid: 8191451, check: true},
{id: 1, userid: 8200249, check: true},
{id: 1, userid: 8181572, check: true},
{id: 1, userid: 8190718, check: true}
],
users: [8191451, 8200249, 8181572, 8190718]
}
使用JSON.stringfy()将obj转换为json字符串,数据如下:
"{"member":[{"id":1,"userid":8191451,"check":true},{"id":1,"userid":8200249,"check":true},{"id":1,"userid":8181572,"check":true},{"id":1,"userid":8190718,"check":true}],"users":[8191451,8200249,8181572,8190718]}"
为了好看,将json字符串写在代码块里
"{"member": [
{"id":1, "userid":8191451, "check":true},
{"id":1, "userid":8200249, "check":true},
{"id":1, "userid":8181572, "check":true},
{"id":1, "userid":8190718, "check":true}],
"users": [8191451,8200249,8181572,8190718]
}"
过了一会儿...后端说你这不对啊你怎么给我字符串,你懂不懂json是啥啊!我说懂啊,我传的不就是json字符串么?后端说我不要json字符串,我要json,我要的是这样的...
{"member": [
{"id":1, "userid":8191451, "check":true},
{"id":1, "userid":8200249, "check":true},
{"id":1, "userid":8181572, "check":true},
{"id":1, "userid":8190718, "check":true}],
"users": [8191451,8200249,8181572,8190718]
}
所以问题就是,前端给后端传json数据不是传json字符串吗?应该传什么格式? 图2/图3?
ps: 感谢回答