如何在JSON中创建列表等效于Kotlin上的列表?
我正在学习KTOR并尝试测试我使用示例模型进行的在这里。但是,我不知道如何在KTOR可以阅读并应作为列表的JSON中列出适当的列表。
我已经尝试过:
{
"number": "2022-04-28",
"contents": {
"OrderItem": {
"item": "Tea",
"amount": 5,
"price": 2.99
},
"OrderItem": {
"item": "Coffee",
"amount": 2,
"price": 4.99
}
}
}
但是每当我尝试发送邮政请求时,我都会遇到内部服务器错误。
I'm learning Ktor and trying to test a POST request implementation I made using the example model given here. However, I have no idea how to make a proper list in JSON that Ktor could read and deserialize as a list.
I've tried:
{
"number": "2022-04-28",
"contents": {
"OrderItem": {
"item": "Tea",
"amount": 5,
"price": 2.99
},
"OrderItem": {
"item": "Coffee",
"amount": 2,
"price": 4.99
}
}
}
But I get an internal server error whenever I try to send the POST request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目录
应该是列表[]
对象的contents
should be a list[]
of objects