| Id: | 21687 |
| Product: | finPOWER Connect |
| Type: | NEW |
| Version: | 4.01.02 |
| Opened: | 17/07/2024 |
| Closed: | 17/07/2024 |
| Released: | 12/09/2024 |
| Job: | J033921 |
Business Layer; New optional parameter for writing raw JSON
The ISJsonBuilder.WriteRawJson Business Layer function has been updated with a new optional parameter to prefix the raw JSON text with a separator.
This allows coders to include other blocks of raw JSON text correctly when there are other properties before it.
The default for this parameter is FALSE.
Public Function Main(userInterface As ISUserInterfaceBL, reports As ISfinReports, parameters As ISKeyValueList) As BooleanDim JsonBuilder As ISJsonBuilder' Assume SuccessMain = TrueJsonBuilder = finBL.Runtime.CreateJsonBuilder()With JsonBuilder.ObjectBegin().WritePropertyString("PropertyA", "Value A").WritePropertyString("PropertyB", "Value B").WriteRawJson(Me.RawJsonA, True).WriteRawJson(Me.RawJsonB, True).ObjectEnd()End WithfinBL.DebugPrint(JsonBuilder.ToJsonString())End FunctionPrivate Function RawJsonA() As StringDim JsonBuilder As ISJsonBuilderJsonBuilder = finBL.Runtime.CreateJsonBuilder()With JsonBuilder.ObjectBegin("RawJsonA").WritePropertyString("PropertyA", "Raw JSON A Value A", True).WritePropertyString("PropertyB", "Raw JSON A Value B", True).ObjectEnd("RawJsonA")End WithReturn JsonBuilder.ToJsonString()End FunctionPrivate Function RawJsonB() As StringDim JsonBuilder As ISJsonBuilderJsonBuilder = finBL.Runtime.CreateJsonBuilder()With JsonBuilder.ObjectBegin("RawJsonB").WritePropertyString("PropertyA", "Raw JSON B Value A", True).WritePropertyString("PropertyB", "Raw JSON B Value B", True).ObjectEnd("RawJsonB")End WithReturn JsonBuilder.ToJsonString()End Function
Outputs the following raw debug text:
{"PropertyA":"Value A","PropertyB":"Value B", "RawJsonA":{"PropertyA":"Raw JSON A Value A","PropertyB":"Raw JSON A Value B"}, "RawJsonB":{"PropertyA":"Raw JSON B Value A","PropertyB":"Raw JSON B Value B"}}
This can be viewed as JSON:
{
"PropertyA": "Value A",
"PropertyB": "Value B",
"RawJsonA": {
"PropertyA": "Raw JSON A Value A",
"PropertyB": "Raw JSON A Value B"
},
"RawJsonB": {
"PropertyA": "Raw JSON B Value A",
"PropertyB": "Raw JSON B Value B"
}
}