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 Boolean
Dim JsonBuilder As ISJsonBuilder
' Assume Success
Main = True
JsonBuilder = finBL.Runtime.CreateJsonBuilder()
With JsonBuilder
.ObjectBegin()
.WritePropertyString("PropertyA", "Value A")
.WritePropertyString("PropertyB", "Value B")
.WriteRawJson(Me.RawJsonA, True)
.WriteRawJson(Me.RawJsonB, True)
.ObjectEnd()
End With
finBL.DebugPrint(JsonBuilder.ToJsonString())
End Function
Private Function RawJsonA() As String
Dim JsonBuilder As ISJsonBuilder
JsonBuilder = 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 With
Return JsonBuilder.ToJsonString()
End Function
Private Function RawJsonB() As String
Dim JsonBuilder As ISJsonBuilder
JsonBuilder = 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 With
Return 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"
}
}