1 ' Copyright (c) Microsoft Corporation. All rights reserved.
5 Imports System
.Runtime
.Serialization
6 Imports System
.Runtime
.Serialization
.Json
8 Namespace Microsoft
.Ajax
.Samples
11 Public Shared
Sub Main()
16 Dim stream1
As New MemoryStream()
18 'Serialize the Person object to a memory stream using DataContractJsonSerializer.
19 Dim ser
As New DataContractJsonSerializer(GetType(Person
))
20 ser
.WriteObject(stream1
, p
)
24 Dim sr
As New StreamReader(stream1
)
25 Console
.Write("JSON form of Person object: ")
26 Console
.WriteLine(sr
.ReadToEnd())
28 'Deserialize the JSON back into a new Person object
30 Dim p2
As Person
= DirectCast(ser
.ReadObject(stream1
), Person
)
33 Console
.Write("Deserialized back, got name=")
34 Console
.Write(p2
.name
)
35 Console
.Write(", age=")
36 Console
.WriteLine(p2
.age
)
38 Console
.WriteLine("Press <ENTER> to terminate the program.")