jsonata-js/jsonata

how to access the key value in a object which is outside of the object.

Closed this issue · 4 comments

{
"isVisibleCondition": true,
"Questions": [
{
"QuestionChoices": [
{
"choiceTextInDefaultLanguage": "YES",
"isDefault": false,
"scoringValue": 0
},
],
"textDataType": 0
}
],
"visibleCondition": {
"filterConditions": [
{
"fieldCondition": {
"answerCode": "NO",
"questionCode": "Q3"
},

      }
    ]
  }
}, in this how to access isVisibleCondition" inside the answercode of visibleCondition

This expression demos 3 ways to do it. https://try.jsonata.org/vusDWtfWM

$.(
    $isViz:=isVisibleCondition;
    visibleCondition.{
        "filters": filterConditions,
        "isViz": $$.isVisibleCondition,   /* root input variable */
        "isViz2" : %.isVisibleCondition, /* parent operator */
        "isViz3": $isViz                            /* captured in variable */
    }
)

BTW, you could have made this a lot easier with a well-formatted JSON.

Thank you for the response @markmelville , it helped me a lot

On the exerciser page, there is a button to get an invite to the slack group. I suggest you join that to get more help.

Thanks for helping out here, @markmelville 👍