jamppi
asked on
parse json string into model
Hi!
This is my json data and JavaScriptSerializer() is new to me.
i'm using
Dim deserializedDictionary2 As Dictionary(Of String, Object) = deserializer.Deserialize(O f Dictionary(Of String, Object))(json)
and with this i get it into a dictionary containing arraylist.
i have 2 questions
1.how do i get the values from the arraylists
2. i would prefer to have the data in a model
like this
what would be the best way to do that?
This is my json data and JavaScriptSerializer() is new to me.
"products": [{
"id": "27",
"username": "user1",
"recordfile": "file1.3gp",
"status": "1"
},
{
"id": "35",
"username": "user2",
"recordfile": "file2.3gp",
"status": "1"
},
{
"id": "45",
"username": "user3",
"recordfile": "file3.3gp",
"status": "1"
}],
"success": 1
i'm using
Dim deserializedDictionary2 As Dictionary(Of String, Object) = deserializer.Deserialize(O
and with this i get it into a dictionary containing arraylist.
i have 2 questions
1.how do i get the values from the arraylists
2. i would prefer to have the data in a model
like this
Class products
Public id As String
Public username As String
Public recordfile As String
Public status As String
End Class
what would be the best way to do that?
ASKER
well i prefer to use the native JavaScriptSerializer() in .net
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Note the additional braces in lines 6 and 24 to make the data a Javascript object. After the deserialization, you can access the products as:
Open in new window