Current Version: 2.0.1.0as of Business Central 17.
Manual
Creation date: 2024/11/22 The current version of this manual can be found at:
☰ Contents
General
App Serialization Utility Library This Library App provides multiple procedures, which serialize BC Datatypes in JSON Objects...
Tasks
Working with the App Serialization Utility Library
Appendix
Release Notes Would you like to know what has changed in the app...
Docs / NVXSUL Serialization Utility Library / General General
This Library App provides multiple procedures, which serialize BC Datatypes in JSON Objects.
Which can be used to consume a REST Webservice, without having to create the required JSON objects manually.
Docs / NVXSUL Serialization Utility Library / Tasks Working with the App
The Serialize procedures of the Codeunit SULSerializationUtilNVX can be called by an dependent Extension, which require various Parameters:
Parameter
VarToSerialize: Variant -> the Type which shall be serialized
ISerializer: Interface SULISerializerNVX -> Implementation of Serialization e.g. JSON
SerializableType: Enum SULSerializableTypeNVX -> Type of the serializable Datatype
FieldNoSelection: List of [Integer] -> Selection of fields to be serialized (only viable for Record and RecordRef Datatypes)
Further Serialization formats e.g. XML must be implemented by using the Interface SULISerializerNVX and the Enum SULSerializerTypeNVX.
JSON Serialization of Records
procedure GetCustomerAsJSONObject(Customer: Record Customer): JsonObject
var
SerializationUtil: Codeunit SULSerializationUtilNVX;
JObject: JsonObject;
BodyContent: Text;
begin
BodyContent := SerializationUtil.Serialize(Customer, Enum::SULSerializerTypeNVX::JSON, Enum::SULSerializableTypeNVX::Record);
exit(JObject.WriteTo(BodyContent));
end;
procedure GetCustomerSelectedFieldsAsJSONObject(Customer: Record Customer; SlectedFields: List of [Integer]): JsonObject
var
SerializationUtil: Codeunit SULSerializationUtilNVX;
JObject: JsonObject;
BodyContent: Text;
begin
BodyContent := SerializationUtil.Serialize(Customer, Enum::SULSerializerTypeNVX::JSON, SelectedFields, Enum::SULSerializableTypeNVX::Record);
exit(JObject.WriteTo(BodyContent));
end;
JSON Deserialization of Records
local procedure UpdateCustomerFromApi(CustomerNo: Code[20]; Response: Text)
var
Customer: Record Customer;
ThrowError: Codeunit AppThrowErrorNVX;
SerializationUtil: Codeunit SULSerializationUtilNVX;
JsonFieldMapping: Dictionary of [Integer, Text];
DeserializationFailed: List of [Text];
Json: JsonObject;
begin
//JsonFieldMapping consists of the Field No. of the BC Record as key and the respective Json Token from the response as value
//DeserializationFailed contains the Json Tokens which must be deserialized manually
ThrowError.IfCustomerDoesNotExist(Customer, CustomerNo);
JsonFieldMapping.Add(2, 'name');
JsonFieldMapping.Add(4, 'name2');
Json.ReadFrom(Response);
SerializationUtil.Deserialize(
Json,
MKSHeader,
Enum::SULDeserializerTypeNVX::JSON,
JsonFieldMapping,
DeserializationFailed);
end;
Would you like to know what has changed in the app?
Below you'll find an overview about new features and changes that has been done in the updates.
Build-Overview in DevOps
NVXSUL 2.0.2.0
Modifications
Adaptations for BC 23 compatibility.
NVXSUL 2.0.1.0
as of Business Central 17 2022/02/03
Improvements
Implement JSON deserialization functionality for not yet inserted records.
NVXSUL 2.0.0.0
as of Business Central 17 2022/01/26
Improvements
Implement JSON deserialization functionality based on Record datatypes.