我希望有人可以帮助我解决将数据序列化到课程中的问题吗?
我需要将以下 json 字符串发送到 Web 服务:
{ "arrivalAt": "2012-12-24T20:00:00.0000000Z", "pickup":{"streetName":"Amaliegade","houseNumber":"36","zipCode":"1256","city" :"Copenhagen K","country":"DK","lat":55.68,"lng":12.59}, "dropoff":{"streetName":"Amaliegade","houseNumber":"36","zipCode ":"1256","city":"Copenhagen K","country":"DK","lat":55.68,"lng":12.59}, "vehicleType": "fourSeaterAny", "comments": "你好" }'
我将此 json 字符串放入http://json2csharp.com/并生成以下类:
public class Pickup
{
public string streetName { get; set; }
public string houseNumber { get; set; }
public string zipCode { get; set; }
public string city { get; set; }
public string country { get; set; }
public double lat { get; set; }
public double lng { get; set; }
}
public class Dropoff
{
public string streetName { get; set; }
public string houseNumber { get; set; }
public string zipCode { get; set; }
public string city { get; set; }
public string country { get; set; }
public double lat { get; set; }
public double lng { get; set; }
}
public class RootObject
{
public string arrivalAt { get; set; }
public Pickup pickup { get; set; }
public Dropoff dropoff { get; set; }
public string vehicleType { get; set; }
public string comments { get; set; }
}
我以前曾设法做到这一点,但从来没有遇到过班级中有班级的情况,可以这么说。意思是“Pickup”和“DropOff”设置......
当我试图弄清楚在这条线上该怎么做时,我被卡住了......
Booking bookingdetails = new ClickATaxi_Classes.Booking(THIS IS WHERE I WILL PUT THE 17 BITS OF INFORMATION BUT HOW?);
我觉得我需要对班级做一些事情以使其接受争论,但我不知道从哪里开始以及如何发送接送信息
有人可以帮忙吗?
谢谢