Imports System
Imports System.Linq
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.IO
Imports System.Globalization
Imports System.Reflection
Imports System.ComponentModel.DataAnnotations
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Converters
Imports Newtonsoft.Json.Serialization
Imports NUnit.Framework
' https://stackoverflow.com/questions/53565130/how-can-i-do-this-an-easier-way
Public Module TestClass
Friend Sub Test()
Dim data As String = "John Doe"
Dim example = New With { _
.fields = {"name","Company.name","email","mobile"}, _
.query = New With { _
.group = New With { _
.[operator] = "AND", _
.rules = { _
New With { _
.condition = "CONTAINS", _
.moduleName = "Contact", _
.field = new With { .fieldName = "name" }, _
.data = data _
} _
}
Dim json as String = JsonConvert.SerializeObject(example, Formatting.Indented)
Console.WriteLine(json)
End Sub
End Module
Public Module Module1
Public Sub Main()
Console.WriteLine("Environment version: " & Environment.Version.ToString())
Console.WriteLine("Json.NET version: " & GetType(JsonSerializer).Assembly.FullName)
Console.WriteLine("")
Try
TestClass.Test()
Catch ex as Exception
Console.WriteLine("Unhandled exception: ")
Console.WriteLine(ex)
Throw
End Try