JSON Null Value Normalization for OutSystems 11
NormalizeJsonNulls is a reusable C# extension 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 default values while preserving existing non-null data.
It supports primitive data types, nested objects, lists, and complex structures without requiring manual attribute mapping.
Automatic Type Detection: Identifies the expected data types using the provided Structure.
Null Value Normalization: Replaces null values with defaults based on their data types.
Nested Object Support: Recursively processes objects with multiple nesting levels.
Automatic Object Expansion: Expands null objects and populates their attributes with default values.
List Support: Converts null lists into empty arrays ([]).
[]
Null List Elements: Normalizes null elements within lists according to their expected types.
Data Preservation: Preserves existing non-null values.
Reusable Component: Supports different Structures through a single Server Action.
Receives the original JSON and a reference Structure, returning a normalized JSON response.
Parameter
Data Type
Description
Json
Text
Original JSON content to be analyzed and normalized.
Structure
Object
Reference Structure used to identify the expected data types of the attributes.
Result
Normalized JSON containing default values in place of null values.
Original Value
Normalized Value
""
Integer / Decimal
0
Boolean
false
DateTime
"1900-01-01T00:00:00"
Nested Object
Object with default values
List
Null List Element
Default value according to its type
{ "name": "Leonardo", "age": null, "active": null, "address": { "street": null, "number": null }, "phones": null, "tags": ["vip", null, "premium"] }
{ "name": "Leonardo", "age": 0, "active": false, "address": { "street": "", "number": 0 }, "phones": [], "tags": ["vip", "", "premium"] }
Existing non-null values are preserved. Only null values are replaced according to the reference Structure.
Install NormalizeJsonNulls from the OutSystems Forge.
Open your application in Service Studio.
Add the NormalizeJsonNulls dependency.
NormalizeJsonNulls
Create a variable based on the Structure representing your JSON response.
Call the NormalizeJsonNulls Server Action.
Pass the original JSON to the Json parameter.
Pass the reference Structure using ToObject(MyStructure).
ToObject(MyStructure)
Use the Result output as your normalized JSON.
Json = Response.ResponseText Structure = ToObject(MyStructure) Output: Result = Normalized JSON
Handling null values in external REST API responses.
Preparing JSON payloads before deserialization.
Processing complex JSON containing nested objects and lists.
Standardizing external integration data.
Reducing repetitive null-handling logic across applications.
Property
Details
Platform
OutSystems 11
Technology
C# / .NET
Module Type
Extension
Execution
Server-side
Application Type
Reactive Web and compatible OutSystems 11 applications
NormalizeJsonNulls intentionally replaces JSON null values with default values based on the provided Structure.
This behavior may change the original meaning of API responses. For example, converting null to 0 or false removes the distinction between missing information and an explicitly defined value.
Ensure these conversions are appropriate for your integration requirements.
The component has been tested with complex Structures containing nested objects, lists of objects, primitive lists, and null elements.
Try the component: NormalizeJsonNulls — Live Demo