Flatten Object Array

Provides the ability to transform an array of multi-level/complex objects into its flattened representation.

Version 1

HTTP Request
POST /ado/v1/FlattenObjectArray

Header

ParameterDescription
Ocp-Apim-Subscription-KeyThe subscription key you received when you purchased a plan.

Request Body

Mandatory

ParameterTypeDescription
dataobject[]Array of complex, multi-level objects.

Optional

ParameterTypeDescription
delimiterstringThe flattened hierarchy representation of each object will be separated by this string.
balancedOutputbooleantrue will force the resulting output to be structured as a balanced output, false will not. Please see the examples for more information.

Note: Setting this to true has the potential to have an adverse impact on performance but is required if there is a desire to use the filter, sortOrder and schema options.

Common

Further Documentation: Common Parameters

ParameterTypeDescription
filterStringA fully functioning SQL based WHERE statement that will filter the outgoing dataset to the records it determines as being included.
sortOrderObjectSorts the resulting dataset by the criteria provided.
The object should contain property names that represent properties contained within the resulting dataset with a value corresponding to the desired sort direction (i.e. ASC or DESC).
schemaObjectYou can use this parameter to override the inferred schema for properties in the incoming dataset(s).
A field will be inferred unless specific explicitly within this object.
advancedOptionsObjectIs an object with the following properties.

cultureName (String)
The specified culture determines the behaviour for aspects related to formatting numeric values and dates. Is extremely important when converting strings to dates, e.g. 05/03/2022 will be treated differently between locales. For more information on the accepted values for this property, please consult the documentation from Microsoft … https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=net-6.0#culture-names-and-identifiers

isBoolean (string[])
A list of strings that are the names of all properties in the resulting dataset that should be treated as boolean values.

By default, the framework treats boolean values as 1 (true) or 0 (false). In order to differentiate the integer as a boolean, the property in question needs to be called out explicitly in this list.

Notes

The different levels of properties within a complex object will be flattened into a single property whose name will be derived from all properties determined in the hierarchy separated by the delimiter provided.

Arrays and the items within the array will be indicated by the index the item was found at.

Please refer to the examples below for more information.

Examples

Unbalanced
Balanced
restcountries.com

This example demonstrates a complex array of multi-level objects flattened into an array of unbalanced objects.

The resulting items in the array are clearly different and retain their original structure albeit as a flattened representation.

Request

{
    "delimiter": "/",
    "balancedOutput": false,
    "data": [
        {
            "Field3": "Value 1.3",
            "Field4": {
                "Field4.2": "Value 1.4.2",
                "Field4.3": "Value 1.4.3"
            },
            "Field5": [
                {
                    "Field5.1": "Value 1.5.1.1",
                    "Field5.2": "Value 1.5.1.2"
                },
                {
                    "Field5.1": "Value 1.5.2.1",
                    "Field5.2": "Value 1.5.2.2"
                },
                {
                    "Field5.1": "Value 1.5.3.1",
                    "Field5.2": "Value 1.5.4.2"
                }                                
            ]
        },
        {
            "Field1": "Value 1.1",
            "Field2": "Value 1.2",
            "Field4": {
                "Field4.1": "Value 1.4.1",
                "Field4.3": "Value 1.4.3"
            },
            "Field5": [
                {
                    "Field5.1": "Value 1.5.1.1",
                    "Field5.2": "Value 1.5.1.2"
                },
                {
                    "Field5.1": "Value 1.5.3.1",
                    "Field5.2": "Value 1.5.4.2"
                }                                
            ]
        }        
    ]
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "Field3": "Value 1.3",
        "Field4/Field4.2": "Value 1.4.2",
        "Field4/Field4.3": "Value 1.4.3",
        "Field5/0/Field5.1": "Value 1.5.1.1",
        "Field5/0/Field5.2": "Value 1.5.1.2",
        "Field5/1/Field5.1": "Value 1.5.2.1",
        "Field5/1/Field5.2": "Value 1.5.2.2",
        "Field5/2/Field5.1": "Value 1.5.3.1",
        "Field5/2/Field5.2": "Value 1.5.4.2"
    },
    {
        "Field1": "Value 1.1",
        "Field2": "Value 1.2",
        "Field4/Field4.1": "Value 1.4.1",
        "Field4/Field4.3": "Value 1.4.3",
        "Field5/0/Field5.1": "Value 1.5.1.1",
        "Field5/0/Field5.2": "Value 1.5.1.2",
        "Field5/1/Field5.1": "Value 1.5.3.1",
        "Field5/1/Field5.2": "Value 1.5.4.2"
    }
]
Code language: JSON / JSON with Comments (json)