public class Dog
public property Name as String
public property Breed as String
public property Tricks as List(of Trick)
public property Age as Integer
.
.
.
End Class
now if i wanted to have a list of dogs I would do this
Dim dogs as new List(Of Dog)
then lets say I'm reading in from reader a record set of Dogs that was stored in the database:
While reader.Read()
dogs.Add(new Dog(){ Name = reader("Name"), Breed = reader("Breed"), Tricks = new List(Of Trick), Age = reader("Age")})
End While
So now if i wanted to turn that into Json i could call this:
Dim jss as new JavascriptSerializer() string jsonObject = jss.Serialize(dogs)
if i had 2 dogs:
Name= Fido, Breed=Yorkie, Tricks = RollOver, Age = 10
Name = Rex, Breed= BullDog - English, Tricks= Bite, Age = 2
This is what the output would look like as a JSON Object:
[{"Name":"Fido","Breed":"Yorkie","Tricks":[{"Name":"RollOver"}],"Age":"10"},{"Name":"Rex","Breed":"BullDog - English","Tricks":[{"Name":"Bite"}],"Age":"2"}]
This post has been edited by rgfirefly24: 23 October 2012 - 01:11 PM

New Topic/Question
Reply






MultiQuote



|