【发布时间】:2019-08-28 10:40:08
【问题描述】:
我正在尝试将嵌套的 JSON 对象发布到 API。这是我正在尝试的简单代码。
Map m = {
"email": 's@a.com',
"password": "123",
"billing" : {
"first_name": "Samarth",
"last_name": "Agarwal",
}
};
final response = await http.post(url, body: m, headers: {
"Content-Type": "application/json",
"Accept": "application/json"
});
我收到错误消息:
type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'String' in type cast。如果我没有传入 billing 对象,它本身就是另一个映射,那么请求成功完成。
如何在 dart 中使用 HTTP 成功地将嵌套的 JSON 对象发送到 API?
【问题讨论】:
标签: json http post dart flutter