Filter Object Array

Provides the ability to filter an array of multi-level/complex objects by the definition provided.

Version 1

HTTP Request
POST /ado/v1/FilterObjectArray

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.
filterstringA C# style string that performs the filter. Please see more information below on how this string should be constructed.

Property Conversion

This operation works in a dynamic way, therefore, each property of the JSON payload that is being filtered on will need to be statically/strongly typed within the filter statement.

This is achieved via the use of the Convert class in C#.

https://learn.microsoft.com/en-us/dotnet/api/system.convert

There are numerous methods available when it comes to converting from one value type to another but it is likely that only the core set will need to be utilised at any given time.

The core set of methods are listed below.

Convert.ToBoolean()
Convert.ToDateTime()
Convert.ToDecimal()
Convert.ToDouble()
Convert.ToInt32()
Convert.ToInt64()
Convert.ToString()

For more information on built in data types within C#, please refer to this link … https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types

You’re more than welcome to experiment and use the methods other than those listed above.

Please refer to the examples provided for more information on how to apply the conversion.

Comparison Operators

Comparison operators used in the filter process need to follow the C# syntax.

OperatorExplanation
==Equals
>Greater Than
<Less Than
!=Not Equals
>=Greater Than or Equal
<=Less Than or Equal
&&And
||Or

Examples

Example 1
Example 2
Example 3
Example 4

This example demonstrates a complex array of multi-level objects filtered by property numericField3 where the value is greater than or equal to 200.

Request

{
    "filter": "Convert.ToInt32(numericField3) >= 200",
    "data": [
        {
            "textField1": "Value 1.1",
            "textField2": "Value 1.2",
            "textField3": "Value 1.3",
            "numericField1": 744,
            "numericField2": {
                "numericField2_1": 123.456,
                "numericField2_2": 429
            },
            "numericField3": 114
        },
        {
            "textField1": "Value 2.1",
            "textField2": "Value 2.2",
            "textField3": "Value 2.3",
            "numericField1": 987,
            "numericField2": {
                "numericField2_1": 456.789,
                "numericField2_2": 562
            },
            "numericField3": 265
        },
        {
            "textField1": "Value 3.1",
            "textField2": "Value 3.2",
            "textField3": "Value 3.3",
            "numericField1": 235,
            "numericField2": {
                "numericField2_1": 424.231,
                "numericField2_2": 246
            },
            "numericField3": 946
        }
    ]
}
Code language: JSON / JSON with Comments (json)

Request

[
    {
        "textField1": "Value 1.1",
        "textField2": "Value 1.2",
        "textField3": "Value 1.3",
        "numericField1": 744,
        "numericField2": {
            "numericField2_1": 123.456,
            "numericField2_2": 429
        },
        "numericField3": 114
    },
    {
        "textField1": "Value 2.1",
        "textField2": "Value 2.2",
        "textField3": "Value 2.3",
        "numericField1": 987,
        "numericField2": {
            "numericField2_1": 456.789,
            "numericField2_2": 562
        },
        "numericField3": 265
    }
]
Code language: JSON / JSON with Comments (json)