反序列化对象的对象

时间:2019-04-17 12:26:31

标签: .net json

以下JSON字符串由我们使用的软件的api提供。我无法控制JSON的格式,因此这是我必须使用的方法。我在正确设置类结构时遇到以下JSON字符串问题。以下是我尝试的一些代码示例。任何帮助将不胜感激。

该功能似乎失败了,并给出以下错误:{“解析值时遇到意外字符:{。路径'framework.competencies',第1行,位置169。”}。对于“ scale”类结构,我也得到了相同的错误消息。

Dim frameworks = JsonConvert.DeserializeObject(Of FrameWorkDetails.RootObject)(jsonString)

JSON:

{
  ""type"": ""framework"",
  ""limit"": 0,
  ""offset"": 0,
  ""total"": 9,
  ""time"": ""0.066s"",
  ""framework"": {
    ""id"": ""5228"",
    ""name"": ""CFPClassroomObservationRubric"",
    ""description"": null,
    ""competencies"": {
      ""2279-1"": {
        ""id"": ""2279-1"",
        ""code"": ""CFP1"",
        ""name"": ""TeacherIntroducesVirtue,
                  Story,
                  HistoricalBackgroundandBigQuestion"",
    ""parent"": null
  },
  ""2279-2"": {
    ""id"": ""2279-2"",
    ""code"": ""CFP2"",
    ""name"": ""CharacterFormingProcess: ExperienceIt"",
    ""parent"": null
  },
  ""2279-3"": {
    ""id"": ""2279-3"",
    ""code"": ""CFP3"",
    ""name"": ""CharacterFormingProcess: InternalizeIt(Identity)"",
    ""parent"": null
  },
  ""2279-4"": {
    ""id"": ""2279-4"",
    ""code"": ""CFP4"",
    ""name"": ""CharacterFormingProcess: InternalizeIt(Purpose)"",
    ""parent"": null
  },
  ""2279-5"": {
    ""id"": ""2279-5"",
    ""code"": ""CFP5"",
    ""name"": ""CharacterFormingProcess: InternalizeIt(Action)"",
    ""parent"": null
  },
  ""2279-6"": {
    ""id"": ""2279-6"",
    ""code"": ""CFP6"",
    ""name"": ""CharacterFormingProcess: ActivateIt"",
    ""parent"": null
  }
},
""bounds"": [

],
""scale"": {
  ""1"": ""Unsatisfactory"",
  ""2"": ""ApproachingProficient"",
  ""3"": ""Proficient"",
  ""4"": ""Mastery""
}
}
}

班级:

Public Class FrameWorkDetails

Public Class Competencies
    Public Property id As Integer
    Public Property code As String
    Public Property name As String
End Class

Public Class Bounds
    Public Property min As String
    Public Property max As String
    Public Property precision As String
End Class

Public Class Framework
    Public Property id As Integer
    Public Property name As String
    Public Property description As String
    Public Property competencies As Dictionary(Of Competencies, String)
    Public Property bounds As List(Of Bounds)
    Public Property scale As Dictionary(Of String, Double)

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 framework As Dictionary(Of String, String)
    Public Property items_count As Integer
End Class

End Class

0 个答案:

没有答案