如何在json数组下发布?
"LstUserOptions": [
{
"OptionID": "ca339e40-10cc-4459-b9ec-07f7df0f4c69"
}
]
最佳答案
我找到了解决方案:
List<Map> carOptionJson = new List();
CarJson carJson = new CarJson("ca339e40-10cc-4459-b9ec-07f7df0f4c69");
carOptionJson.add(carJson.TojsonData());
var body = json.encode({
"LstUserOptions": carOptionJson
});
http.Response response = await http.post(
Uri.encodeFull(ConfigApi.SAVE),
body: body,
headers: {'Content-type': 'application/json'});
class CarJson {
String OptionID;
CarJson(this.OptionID);
Map<String, dynamic> TojsonData() {
var map = new Map<String, dynamic>();
map["OptionID"] = OptionID;
return map;
}
}
关于dart - Flutter 如何发布 json 数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53002196/