NormalizeJsonNulls is a reusable C# extension for OutSystems 11 that automatically normalizes null values in JSON responses based on the data types defined in a reference Structure.
null
The component uses C# Reflection to identify attribute types dynamically, replacing null values with their corresponding defaults while preserving existing data.
It supports primitive data types, nested objects, lists, and complex structures without requiring manual mapping of individual attributes.
Automatic Type Detection: Uses the provided Structure to identify the expected data types.
Null Value Normalization: Converts null values into appropriate defaults for Text, Integer, Decimal, Boolean, and other supported types.
Nested Object Support: Recursively processes complex objects at multiple levels.
Automatic Object Expansion: Expands null objects and initializes their attributes with default values.
List Support: Converts null lists into empty arrays ([]).
[]
Null List Item Handling: Normalizes null elements within lists according to their expected types.
Data Preservation: Keeps existing non-null values unchanged.
Reusable Integration: Works with different Structures through a single Server Action.
The extension receives the original JSON and a reference Structure converted into an Object using ToObject().
ToObject()
It uses C# Reflection to inspect the Structure's data types and recursively normalize the corresponding JSON attributes.
For example, the following JSON:
{ "name": null, "age": null, "active": null, "address": { "street": null, "number": null }, "phones": null }
Is normalized into:
{ "name": "", "age": 0, "active": false, "address": { "street": "", "number": 0 }, "phones": [] }
The resulting JSON can then be used in REST integrations, deserialization workflows, or other data-processing operations.
NormalizeJsonNulls
Input Parameters:
Json (Text): Original JSON content to be analyzed and normalized.
Json
Structure (Object): Reference Structure used to identify the expected data types.
Structure
Output Parameter:
Result (Text): Normalized JSON containing the corresponding default values.
Result
Add the NormalizeJsonNulls dependency to your application.
Create a variable using the Structure that represents your JSON response.
Call the NormalizeJsonNulls Server Action.
Pass the original JSON to the Json parameter.
Pass ToObject(MyStructure) to the Structure parameter.
ToObject(MyStructure)
Use the returned Result as the normalized JSON.
Handling null values in external REST API responses.
Preparing JSON payloads before deserialization.
Processing complex JSON responses containing nested objects and lists.
Standardizing JSON data for integration workflows.
Reducing repetitive null-handling logic across applications.
Platform: OutSystems 11
Technology: C# / .NET
Module Type: Extension
Execution: Server-side
Supported Applications: Reactive Web and other OutSystems 11 applications that can consume the extension.
Note: Normalization intentionally replaces JSON null values with defaults, which may change their original meaning. Ensure this behavior matches your integration requirements.
https://jah.outsystemscloud.com/NormalizeJsonNullsDemo
? If this component helps you, please leave a review on the OutSystems Forge! Your feedback is greatly appreciated.