如何使用JsontextWriter ...
格式化此结构 "truck": {
"number": "9999",
"type": "FM",
"vinNumber": "vin750",
"licensePlate": {
"number": "12345",
"stateProvince": "IN"
}
},
我的问题是卡车对象结构中的"许可板"结构。到目前为止,我的代码看起来像这样,但行不通...
writer.WriteStartObject();
writer.WritePropertyName("data");
writer.WriteValue("TEST");
writer.WritePropertyName("tripNumber");
writer.WriteValue("TTEST001");
writer.WritePropertyName("estimatedArrivalDateTime");
writer.WriteValue(new DateTime(2014, 01, 14, 15,20,00));
writer.WritePropertyName("truck");
//writer.WriteRaw("{");
writer.WriteStartObject();
writer.WritePropertyName("number");
writer.WriteValue("123");
writer.WritePropertyName("type");
writer.WriteValue("FM");
writer.WritePropertyName("vinNumber");
writer.WriteValue("vintest1234");
writer.WritePropertyName("licensePlate");
writer.WriteEnd();
//writer.WriteEndObject();
writer.WritePropertyName("number");
writer.WriteValue("truck plate#");
writer.WritePropertyName("stateProvince");
writer.WriteValue("IN");
writer.WriteEndObject();
我找到了答案。
writer.WritePropertyName("licensePlate");
writer.WriteStartObject();
writer.WritePropertyName("number");
writer.WriteValue("truck plate#");
writer.WritePropertyName("stateProvince");
writer.WriteValue("IN");
writer.WriteEndObject();
写入搞砸了...