Article Details
Id:13055
Product:finPOWER Connect
Type:NEW
Version:2.03.00
Opened:23/06/2015
Closed:01/07/2015
Released:09/07/2015
Job: J015769

Business Layer; added JSON Builder class

A new class has been added to the finPOWER Connect Business Layer to make it easy to build JSON strings.

This is found in the Runtime namespace. A code example is shown below:

  With finBL.Runtime.CreateJsonBuilder(True)
    .ObjectBegin()

    .WritePropertyString("AccountId", "L1000")

    .ArrayBegin("Payments")

    .ObjectBegin()
    .WritePropertyDate("Date", #5/1/2015#)
    .WritePropertyString("Reference", "AP")
    .WritePropertyDecimal("Value", 120) 
    .ObjectEnd()

    .ObjectBegin()
    .WritePropertyDate("Date", #6/1/2015#)
    .WritePropertyString("Reference", "DD")
    .WritePropertyDecimal("Value", 125)
    .ObjectEnd()

    .ArrayEnd("Payments")
    
    .ObjectEnd()

    finBL.DebugPrint(.ToJsonString)
  End With

This produces the following JSON string:

{ "AccountId": "L1000", "Payments": [ { "Date": "2015-05-01T00:00:00", "Reference": "AP", "Value": 120.0 }, { "Date": "2015-06-01T00:00:00", "Reference": "DD", "Value": 125.0 } ] }