【发布时间】:2016-06-17 01:36:08
【问题描述】:
我构建了以下要存储数据的类(帮助也可以在 c# 中)
Public Class DatasourceInfos
Public Property DSContainer() As List(Of DatasourceInfo)
End Class
Public Class DatasourceInfo
Public Property name As String
Public Property description As String
Public Property created As String
Public Property modified As String
Public Property identifier As String
Public Property href As String
Public Property cacheAvailable As Boolean
Public Property id As ULong
End Class
我接收json格式的数据如下:
[{ "name":"MyName1",
"description":"MyDescription1",
"created":1244193265000,
"modified":1264515442000,
"identifier":"Identifier==",
"href":"https://....",
"cacheAvailable":true,
"id":29},
{"name":"MyName2",
"description":"MyDescription2",
"created":1244193265000,
"modified":1264515442000,
"identifier":"Identifier==",
"href":"https://....",
"cacheAvailable":true,
"id":30}]
使用RestSharp(解决方案不得使用RestSharp)我尝试通过以下方式将数据放入我的班级:
Public Function getDatasources(ByVal _token As String) As String
Dim client = New RestClient(_baseURI)
Dim request = New RestRequest("/data", Method.GET)
request.AddHeader("Authorization", "Basic " + _token)
Dim response = client.Execute(Of DatasourceInfos)(request)
Return response
End Function
但是查看response object 并没有映射到我的课程。谁能告诉我我做错了什么?我将这段代码与SO 上的许多其他代码进行了比较,但我就是看不出有什么问题。
【问题讨论】:
标签: c# json vb.net deserialization restsharp