我无法使用键和值对传递postman中的json数组。 当像这样工作时使用
[
{
"serviceTypeId": 40,
"serviceName": "standard Cut2",
"active": true,
},
{
"serviceTypeId": 44,
"serviceName": "Special Cut1",
"active": true,
},
{
"serviceTypeId": 46,
"serviceName": "Feather xxxy",
"active": true,
}
]
但是当我添加一个密钥时(即如下)
{"serviceType": [
{
"serviceTypeId": 40,
"serviceName": "standard Cut2",
"active": true,
},
{
"serviceTypeId": 44,
"serviceName": "Special Cut1",
"active": true,
},
{
"serviceTypeId": 46,
"serviceName": "Feather xxxy",
"active": true,
}
]
}
答案 0 :(得分:0)
您的Json格式不正确,活动属性后还有一个额外的逗号。去掉它。它应该是:
[
{
"serviceTypeId":40,
"serviceName":"standard Cut2",
"active":true
},
{
"serviceTypeId":44,
"serviceName":"Special Cut1",
"active":true
},
{
"serviceTypeId":46,
"serviceName":"Feather xxxy",
"active":true
}
]
在数组中尝试:
{
"serviceType":[
{
"serviceTypeId":40,
"serviceName":"standard Cut2",
"active":true
},
{
"serviceTypeId":44,
"serviceName":"Special Cut1",
"active":true
},
{
"serviceTypeId":46,
"serviceName":"Feather xxxy",
"active":true
}
]
}
如果您对自己的JSON不确定,可以使用互联网上的工具:https://jsonformatter.curiousconcept.com/。
如果您的json是正确的,您将能够快速查看。