KNIME JSON Transformer examples

Hello,

Could someone forward me to a tutorial, or an example how to use the JSON tranformer? I struggle to understand how it’s supposed to work…

It’s kind of a long story, but I’m trying to tweak some output from the JSON row combiner.

From this:

{
"Data": {
    "Identifier": "C41_Decke",
    "DisplayName": "C4.1 Decke",
    "Description": "C4.1 Decke",
    "Conditions": [
        {
            "Condition": "IsEqual",
            "Parameters": [
                {
                    "Parameter": "LHS",
                    "FixedFieldGroup": "$IFC",
                    "FixedFieldName": "$Type"
                },
                {
                    "Parameter": "RHS",
                    "Value": "IfcSlab"
                },
                {
                    "Parameter": "Type",
                    "Value": "String"
                }
            ]
        },
        {
            "Condition": "IsEqual",
            "Parameters": [
                {
                    "Parameter": "LHS",
                    "FixedFieldGroup": "$Classification.EBKP-H",
                    "FixedFieldName": "relatingclassification:itemreference"
                },
                {
                    "Parameter": "RHS",
                    "Value": "C4.1"
                },
                {
                    "Parameter": "Type",
                    "Value": "String"
                }
            ]
        }
    ]
}

}

To this (target):

{
"Data": {
    "Identifier": "C41_Decke",
    "DisplayName": "C4.1 Decke",
    "Description": "C4.1 Decke",
    "Conditions": [
        {
            "Condition": "IsEqual",
            "Parameters": [
                {
                    "Parameter": "LHS",
                    "FixedFieldGroup": "$Classification.EBKP-H",
                    "FixedFieldName": "relatingclassification:itemreference"
                },
                {
                    "Parameter": "RHS",
                    "Value": "C4.1"
                },
                {
                    "Parameter": "Type",
                    "Value": "String"
                }
            ],
            "Conditions": [
                {
                    "Condition": "IsEqual",
                    "Parameters": [
                        {
                            "Parameter": "LHS",
                            "FixedFieldGroup": "$IFC",
                            "FixedFieldName": "$Type"
                        },
                        {
                            "Parameter": "RHS",
                            "Value": "IFCSLAB"
                        },
                        {
                            "Parameter": "Type",
                            "Value": "String"
                        }
                    ]
                }
            ]
        }
    ]
}

}

The second condition has to be nested in the first condition. I feel like the JSON transform should make this work, but I can’t figure it out. Thanks in advance.

1 Like

So, figured it out. In case anyone finds this later, with the same question.

The JSON mapper works like this:

image

The confusing part was how to define a correct path and the syntax is: “/Parent_Name/Child_Index”. In my case: “/Parameters/3”

2 Likes

Another example:

It’s kind of obvious now, but took me forever to figure out. :expressionless:

1 Like

Hello @dr_snglr,

glad you figured it out. If you think this might be interesting to others you can also create an example and upload it to KNIME Hub so others can find it more easiliy, download it and try it out :wink:

Br,
Ivan

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.