Post class Shopware 客户列表中的对象 Api
Post class object with list in Shopware Customer Api
我想 post 我的数据列表给 shopware 客户 api。当我在 JSON 中转换我的 class 对象时,列表不包含在所有其他数据中。但是我不知道如何将我的列表与所有 class 对象数据绑定并通过 api 发送到。
我想像下面的例子一样发送数据
{
"email": "meier@mail.de",
"firstname": "Max",
"lastname": "Meier",
"salutation": "mr",
"billing": {
"firstname": "Max",
"lastname": "Meier",
"salutation": "mr",
"street": "Musterstrasse 55",
"city": "Sch\u00f6ppingen",
"zipcode": "48624",
"country": 2
}
}
这是我的 Class
public class Customer
{
public string email;
public string salutation;
public string title;
public string firstname;
public string lastname;
public string street;
public string city;
public string zipcode;
public int country;
private List<Customer> billing;
public Customer()
{
}
public Customer(List<Customer> billing)
{
this.billing = billing;
}
}
控制器
List<Customer> billing = new List<Customer>();
billing.Add(new Customer()
{
firstname = "Hassas",
lastname = "sssss",
salutation = "mr",
street = "Haupt Str 11",
city = "abcddd",
zipcode = "4900",
country = 2
});
var shopCustomer = new Customer(billing);
shopCustomer.firstname = customers.FirstName;
shopCustomer.lastname = customers.LastName;
shopCustomer.email = customers.Email;
shopCustomer.salutation = "mr";
customershopwareApi.getCustomerRessource().add(shopCustomer);
Customer customer = new Customer();
customer.email = "abc@gmail.com";
customer.firstname = "abc";
customer.lastname = "defg";
customer.salutation = "mr";
Billing billing = new Billing
{
firstname = "abc",
lastname = "defgh",
salutation = "mr",
street = "Haupt str 11",
city = "Hieer",
zipCode = "4176",
country = 2
};
customer.billing = billing;
shopwareApi.getCustomerRessource().add(customer);
我想 post 我的数据列表给 shopware 客户 api。当我在 JSON 中转换我的 class 对象时,列表不包含在所有其他数据中。但是我不知道如何将我的列表与所有 class 对象数据绑定并通过 api 发送到。 我想像下面的例子一样发送数据
{
"email": "meier@mail.de",
"firstname": "Max",
"lastname": "Meier",
"salutation": "mr",
"billing": {
"firstname": "Max",
"lastname": "Meier",
"salutation": "mr",
"street": "Musterstrasse 55",
"city": "Sch\u00f6ppingen",
"zipcode": "48624",
"country": 2
}
}
这是我的 Class
public class Customer
{
public string email;
public string salutation;
public string title;
public string firstname;
public string lastname;
public string street;
public string city;
public string zipcode;
public int country;
private List<Customer> billing;
public Customer()
{
}
public Customer(List<Customer> billing)
{
this.billing = billing;
}
}
控制器
List<Customer> billing = new List<Customer>();
billing.Add(new Customer()
{
firstname = "Hassas",
lastname = "sssss",
salutation = "mr",
street = "Haupt Str 11",
city = "abcddd",
zipcode = "4900",
country = 2
});
var shopCustomer = new Customer(billing);
shopCustomer.firstname = customers.FirstName;
shopCustomer.lastname = customers.LastName;
shopCustomer.email = customers.Email;
shopCustomer.salutation = "mr";
customershopwareApi.getCustomerRessource().add(shopCustomer);
Customer customer = new Customer();
customer.email = "abc@gmail.com";
customer.firstname = "abc";
customer.lastname = "defg";
customer.salutation = "mr";
Billing billing = new Billing
{
firstname = "abc",
lastname = "defgh",
salutation = "mr",
street = "Haupt str 11",
city = "Hieer",
zipCode = "4176",
country = 2
};
customer.billing = billing;
shopwareApi.getCustomerRessource().add(customer);