运行以下代码时出现错误:
http.post(url,
body: {"access_token": "bfa67f6f8389f421d8ac0106f040d19b40d8a69112402a76b87d66aea86a",
"title": "HelloWorld!",
"content": [{
"tag": "p",
"children":
["Hello world!"]
}
],
"return_content": true
},
我知道 dart 在提示,因为我有一个 array which contains a map within my map . 我该如何处理?
编辑: 我通常会将其编码为 JSON,但 API只接受字符串
最佳答案
body
参数的类型必须是 String
,但事实并非如此。
您的值看起来像一个类似 JSON 的结构,因此您可能希望使用 json
编码器将该对象结构编码为 String:
import "dart:convert";
...
var body = jsonEncode({"access_token": "..... " ... });
http.post(url, body: body);
关于http - 在类型转换中出现错误 "type ' List<Map<String, Object>>' is not a subtype of type ' String',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51896468/