I’ve got the following JSON string to deserialize:
[{"application_id":"1","application_package":"abc"},{"application_id":"2","application_package":"xyz"}]
I’m using DataContractJsonSerializer method.
It is made up of array of items and I couldn’t find an example using VB.Net that can deserialize this structure. I have the following Application class to store this information:
<DataContract(Namespace:="")> _
Public Class ApplicationItem
<DataMember(Name:="application_id")>
Public Property application_id As String
<DataMember(Name:="application_package")>
Public Property application_package As String
End Class
I’d recommend you to use
JavaScriptSerializeroverDataContractJsonSerializer. The reasons are:JavaScriptSerializeris faster overDataContractJsonSerializerDataContractJsonSerializerrequires more code thanJavaScriptSerializerfor a simple serialization.You won’t need the
DataContractandDataMemberattribute to use along withJavaScriptSerializerUse this data class
And use this to deserialize your
jsonText:If you still want to use
DataContractJsonSerializer, you can use this code below to deserialize:Courtesy: Used Telerik Code Converter