系统要求我从与http://jsonapi.org/相同格式的json中读取命令
这里是一个示例,请注意,其中一些名称中包含“-”,例如:order-totals
,order-products
"data": [
{
"type": "orders",
"attributes": {
"customer_address_name": "testTestmann",
"customer_address_company": "",
"customer_address_zipcode": "9022",
"customer_address_state": "uk",
},
"relationships": {
"customer": {
"data": {
"type": "customers",
"id": "1"
}
},
"order-status": {
"data": {
"type": "order-status",
"id": "3"
}
},
"order-totals": {
"links": {
"related": "test2"
}
},
"order-products": {
"links": {
"related": "test1"
}
},
"order-tags": {
"links": {
"related": "test3"
}
},
"order-status-history": {
"links": {
"related": "test4"
}
}
},
这是我用来反序列化的代码:
Dim jsonOrders As String = jutils.GetJsonText(shopurl, shoptoken)
Dim obj = JsonConvert.DeserializeObject(Of MYS_Orders.MyStore_Orders)(jsonOrders)
除了名称中包含“-”的属性外,这对所有属性均适用,因此OrderStatus
当然不会反序列化。
这是对象的样子:
Public Class OrderStatus
Public Property data As Data
End Class
Public Class OrderTotals
Public Property links As Links
End Class
Public Class OrderProducts
Public Property links As Links
End Class
如何用“-”字符命名对象,以便反序列化工作?