Json 当您';你把它放出来却不带进来?
我被告知我需要使用JSON在web上进行flutter通信。我知道如何引入JSON数据并将其转换为Dart对象。我应该如何发布JSON?我应该以Dart对象的形式输出JSON吗?这是怎么回事?我尝试过做研究,但似乎找不到答案。您可以向类中添加一个方法,将其序列化到字典中,如下所示:Json 当您';你把它放出来却不带进来?,json,flutter,Json,Flutter,我被告知我需要使用JSON在web上进行flutter通信。我知道如何引入JSON数据并将其转换为Dart对象。我应该如何发布JSON?我应该以Dart对象的形式输出JSON吗?这是怎么回事?我尝试过做研究,但似乎找不到答案。您可以向类中添加一个方法,将其序列化到字典中,如下所示: class Car { final int nWheels; final String color; Car(this.nWheels, this.color); Map<Strin
class Car {
final int nWheels;
final String color;
Car(this.nWheels, this.color);
Map<String, dynamic> toMap() => {
"nWheels": this.nWheels,
"color": this.color,
}
}
Car car = Car(4, "blue-ish");
String json = jsonEncode(car.toMap());
json
现在是可以传输到服务器的json编码字符串