%REM Copyright 2022-2023 HCL America, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License %END REM Option Public Option Declare ' Modify use statement as appropriate for your environent to point to relative path Use "../../../src/VoltScriptJsonConverter" Class Session Public id as String Public title as String Public products as Variant End Class Class SessionSimple Public id as String Public title as String Public products as String End Class Class SessionExt Public id as String Public title as String Public products() as String End Class Sub Initialize Print "Running Sample1" Call sample1() Print "Running Sample2" Call sample2() Print "Running Sample3" Call sample3() Print "Running Sample4" Call sample4() Print "Running Sample5" Call sample5() End Sub Sub sample1() Dim sess as New Session Dim json as String Dim helper as New JsonConversionHelper sess.id = "Ad16" sess.title = "Collaborate around Business Applications in Communities" sess.products = Split("Domino,Connections,Volt", ",") Print "Products is " & TypeName(sess.products) & " with bounds " & UBound(sess.products) Call helper.withScalarConverter("id").withScalarConverter("title").withArrayConverter("products") json = helper.toJsonString(sess, true) Print json End Sub Sub sample2() Dim sess as New Session Dim json as String Dim helper as New JsonConversionHelper sess.id = "Ad01" sess.title = "Domino HA" sess.products = "Domino" Print "Products is " & TypeName(sess.products) Call helper.withScalarConverter("id").withScalarConverter("title").withArrayConverter("products") json = helper.toJsonString(sess, true) Print json End Sub Sub sample3() Dim sess as New SessionSimple Dim json as String Dim helper as New JsonConversionHelper sess.id = "Ad01" sess.title = "Domino HA" sess.products = "Domino" Print "Products is " & TypeName(sess.products) Call helper.withScalarConverter("id").withScalarConverter("title").withArrayConverter("products") json = helper.toJsonString(sess, true) Print json End Sub Sub sample4() Dim sess as New SessionExt Dim json as String Dim temp as Variant Dim i as integer Dim helper as New JsonConversionHelper sess.id = "Ad16" sess.title = "Colaborate around Business Applications in Communities" temp = Split("Domino,Connections,Volt", ",") Redim sess.products(UBound(temp)) For i = 0 to UBound(temp) sess.products(i) = temp(i) Next Print "Products is " & TypeName(sess.products) & " with bounds " & UBound(sess.products) Call helper.withScalarConverter("id").withScalarConverter("title").withScalarConverter("products") json = helper.toJsonString(sess, true) Print json End Sub Sub sample5() Dim sess as New SessionExt Dim json as String Dim temp as Variant Dim i as integer Dim helper as New JsonConversionHelper sess.id = "Ad01" sess.title = "Domino HA" Redim sess.products(0) sess.products(0) = "Domino" Print "Products is " & TypeName(sess.products) & " with bounds " & UBound(sess.products) Call helper.withScalarConverter("id").withScalarConverter("title").withScalarConverter("products") json = helper.toJsonString(sess, true) Print json End Sub