在将以下JSON字符串转换为.net类时,我遇到了问题。到目前为止,我创建的课程也在下面。我无法上班的特定部分是group_access和role标签。我知道这些是对象数组,但是当我尝试转换对象时,出现以下错误无法将当前JSON对象(例如{“ name”:“ value”})反序列化为类型'System.Array',因为该类型需要JSON数组(例如[1,2,3])正确反序列化。
使用Visual Studio工具(Edit> Paste Special> JSON)和jscon2csharp.com,会在转换角色和group_access标签时出错。
{
id: 122404,
email: 'mike@email.com',
fname: 'Mike',
lname: 'Doe',
full_name: 'Mike Doe',
resource_id: '001002',
title: '',
last_login: '2016-11-01 09:15:23',
tags: [
'Math Department', 'New Teachers'
],
grades: [
4, 5, 6
],
targets: [
'Option 1: 3 Informal Obs.'
],
caseload_tags: [],
group_access: [
10: 2
25527: 1
25645: 1
25653: 4
],
roles: [
10: [
2015: 2,
2016: 2
],
25527: [
2015: 2,
2016: 1
]
25645: [
2015: 1,
2016: 1
]
25653: [
2015: 3,
2016: 4
]
]
}
Public Class Item
Public Property id As Integer
Public Property email As String
Public Property fname As String
Public Property lname As String
Public Property full_name As String
Public Property resource_id As String
Public Property title As String
Public Property tags As IList(Of String)
Public Property grades As IList(Of String)
Public Property targets As IList(Of String)
Public Property group_access As Array
Public Property roles As Array
End Class
Public Class RootObject
Public Property type As String
Public Property limit As Integer
Public Property offset As Integer
Public Property total As Integer
Public Property time As String
Public Property items As List(Of Item)
Public Property items_count As Integer
End Class