Skip to content

Basic operations

MACK Mathieu edited this page Jan 23, 2022 · 2 revisions

This page describes sample operations of transformations on your json content.

It describes json operations. Not C# script to do it as it's already described at the Home page 😀

Selector : JsonPath expression

All selection of data on your json input can be done by using a jsonpath expression.

You can easily test your selector by using this online tool.

Select a field

Sample 1 : Object as parent

This sample describes how to retrieve a field value.

Input :

{
    "field": {
        "subField": true
    }
}

Transformation :

{
    "resultField": "$.field.subField"
}

output :

{
    "resultField": true
}

Sample 2 : Array as root object

This sample describes how to retrieve a field value from an array as input. Input :

[
    {
        "field": true
    },
    {
        "field": false
    }
]

Transformation :

{
    "resultField": "$.[1].field"
}

output :

{
    "resultField": false
}

Select an object in an array

This sample describes how to get the second item on an array :

Input :

{
    "fields": [ "string 1", "string 2"]
}

Transformation :

{
    "resultField": "$.fields[1]"
}

output :

{
    "resultField2": "string 2"
}