我必须将此JSON格式作为发布请求发送到api。但是当在JSONLint上在线检查时,它说这是错误的,错误。请指导创建正确的。以下是JSON格式:
{
"departure_time" = "2017-07-28T17:39:43.611Z";
steps = ({
"encoded_polyline" = "ytfzDqzksM_AgB";
"road_name" = "ytfzDqzksM_AgB";
}, {
"encoded_polyline" = "yvfzDy}ksMPMf@a@";
"road_name" = "yvfzDy}ksMPMf@a@";
}, {
"encoded_polyline" = "_ufzDi_lsM}@mB";
"road_name" = "_ufzDi_lsM}@mB";
}, {
"encoded_polyline" = "}vfzDwblsMb@a@f@a@";
"road_name" = "}vfzDwblsMb@a@f@a@";
}, {
"encoded_polyline" = "qtfzD{dlsMoA}B";
"road_name" = "qtfzD{dlsMoA}B";
});
vehicle = {
axles = 2;
};
}
请指导它出了什么问题以及如何纠正它。
答案 0 :(得分:-1)
首先,必须用逗号分隔分号,除了不需要任何内容的最后一行:
"encoded_polyline" = "qtfzD{dlsMoA}B",
"road_name" = "qtfzD{dlsMoA}B"
要声明一个数组,请使用方括号而不是括号:
"steps" = [{
"encoded_polyline" = "ytfzDqzksM_AgB";
"road_name" = "ytfzDqzksM_AgB";
}, {
"encoded_polyline" = "yvfzDy}ksMPMf@a@";
"road_name = "yvfzDy}ksMPMf@a@";
}]
最后,在JSON中不使用equals符号。相反,请使用冒号:
"departure_time" : "2017-07-28T17:39:43.611Z"
答案 1 :(得分:-1)
经过验证的JSON
{
"departure_time": "2017-07-28T17:39:43.611Z",
"steps": [{
"encoded_polyline": "ytfzDqzksM_AgB",
"road_name": "ytfzDqzksM_AgB"
}, {
"encoded_polyline": "yvfzDy}ksMPMf@a@",
"road_name": "yvfzDy}ksMPMf@a@"
}, {
"encoded_polyline": "_ufzDi_lsM}@mB",
"road_name": "_ufzDi_lsM}@mB"
}, {
"encoded_polyline": "}vfzDwblsMb@a@f@a@",
"road_name": "}vfzDwblsMb@a@f@a@"
}, {
"encoded_polyline": "qtfzD{dlsMoA}B",
"road_name": "qtfzD{dlsMoA}B"
}],
"vehicle": {
"axles": 2
}
}
验证