Imports System.Collections
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Reflection
Imports System.ComponentModel.DataAnnotations
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Converters
Imports Newtonsoft.Json.Serialization
<JsonProperty(PropertyName:="0")> _
Public Property r As Short
<JsonProperty(PropertyName:="1")> _
Public Property g As Short
<JsonProperty(PropertyName:="2")> _
Public Property b As Short
<JsonProperty(PropertyName:="3")> _
Public Property a As Short
Public Property firstName As String
Public Property lastName As String
Public Property values As Values
Public Property employees As Employee()
Dim json as String = GetJson()
Console.WriteLine("Input JSON: ")
Console.WriteLine(JToken.Parse(json))
Dim example = JsonConvert.DeserializeObject(Of Example)(json)
Dim json2 as String = JsonConvert.SerializeObject(example, Newtonsoft.Json.Formatting.Indented)
Console.WriteLine("Re-serialized {0}:", example)
Assert.IsTrue(JToken.DeepEquals(JToken.Parse(json), JToken.Parse(json2)))
Console.WriteLine("Original and re-serialized JSON are identical.")
Function GetJson() as String
Dim Jstring As String = <![CDATA[
Console.WriteLine("Environment version: " & Environment.Version.ToString())
Console.WriteLine("Json.NET version: " & GetType(JsonSerializer).Assembly.FullName)
Console.WriteLine("Unhandled exception: ")
Public Class AssertionFailedException
Public Sub New(message As String)
Public Sub New(message As String, inner As Exception)
MyBase.New(message, inner)
Public Sub IsTrue(value as Boolean, Optional message as String = "failed")
Throw New AssertionFailedException(message)