normalizejsonnulls
Service icon

NormalizeJsonNulls

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 10 Oct (9 hours ago)
 by 
0.0
 (0 ratings)
normalizejsonnulls

NormalizeJsonNulls

Documentation
1.0.0

NormalizeJsonNulls

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.

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.


1. Key Features

  • 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.


2. Available Action

NormalizeJsonNulls

Receives the original JSON and a reference Structure, returning a normalized JSON response.


Input Parameters

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.


Output Parameter

Parameter

Data Type

Description

Result

Text

Normalized JSON containing default values in place of null values.


3. Normalization Rules

Data Type

Original Value

Normalized Value

Text

null

""

Integer / Decimal

null

0

Boolean

null

false

DateTime

null

"1900-01-01T00:00:00"

Nested Object

null

Object with default values

List

null

[]

Null List Element

null

Default value according to its type


4. Before and After Example

Original JSON

{
  "name": "Leonardo",
  "age": null,
  "active": null,
  "address": {
    "street": null,
    "number": null
  },
  "phones": null,
  "tags": ["vip", null, "premium"]
}

Normalized JSON

{
  "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.


5. How to Use

  1. Install NormalizeJsonNulls from the OutSystems Forge.

  2. Open your application in Service Studio.

  3. Add the NormalizeJsonNulls dependency.

  4. Create a variable based on the Structure representing your JSON response.

  5. Call the NormalizeJsonNulls Server Action.

  6. Pass the original JSON to the Json parameter.

  7. Pass the reference Structure using ToObject(MyStructure).

  8. Use the Result output as your normalized JSON.


Example Parameters

Json      = Response.ResponseText
Structure = ToObject(MyStructure)

Output:
Result    = Normalized JSON


6. Typical Use Cases

  • 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.


7. Compatibility

Property

Details

Platform

OutSystems 11

Technology

C# / .NET

Module Type

Extension

Execution

Server-side

Application Type

Reactive Web and compatible OutSystems 11 applications


8. Important Considerations

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.


9. Live Demonstration

Try the component: NormalizeJsonNulls — Live Demo