NEW2.03.00 · Released 9 July 2015
NEWfinPOWER Connect
Released in
2.03.00
9 July 2015
- Opened29 Jun
- Closed1 Jul
- Released9 Jul
Article 13061
Job J015797
Business Layer; added JSON Utilities and Token classes for parsing JSON strings
Two new classes have been added to the finPOWER Connect Business Layer to make it easy to parse JSON strings.
These classes are found in the Runtime namespace. For more information see the finPOWER Connect Business Layer help and Custom Web Services Guide. A code example is shown below:
Public Function Main(ByVal parameters As ISKeyValueList) As BooleanDim i As IntegerDim JsonText As StringDim JsonToken As ISJsonTokenDim JsonTokenRoot As ISJsonTokenDim JsonTokens() As ISJsonToken' Assume SuccessMain = TrueJsonText = "{""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}]}"If finBL.Runtime.JsonUtilities.LoadJsonTokenFromString(JsonText, JsonTokenRoot) ThenfinBL.DebugPrint(String.Format("AccountId : {0}", JsonTokenRoot.GetPropertyString("AccountId")))JsonTokens = JsonTokenRoot.GetPropertyArray("Payments")For i = 0 To JsonTokens.Length - 1JsonToken = JsonTokens(i)finBL.DebugPrint("")finBL.DebugPrint(String.Format("Item {0}", i))finBL.DebugPrint(String.Format("Date : {0}", finBL.FormatDateLong(JsonToken.GetPropertyDate("Date"))))finBL.DebugPrint(String.Format("Reference : {0}", JsonToken.GetPropertyString("Reference")))finBL.DebugPrint(String.Format("Value : {0}", JsonToken.GetPropertyDecimal("Value")))NextElseMain = FalseEnd IfEnd Function
Outputs the following debug text:
AccountId : L1000
Item 0 Date : 01/05/2015 Reference : AP Value : 120
Item 1 Date : 01/06/2015 Reference : DD Value : 125