0

I have a below json object and need to get only c_Internet child object with a condition where the PIID is having value "1234567".

{
  "OrderComponentInfo": {
    "members": {
      "ADD": {
        "DIA": [
          {
            "c_Internet": {
              "PIID": "1234567",
              "IPv6_Multiple_Path_Needed": ""
            },
            "Test": {
              "PIID": "1234567",
              "INT_Acc_MSP_ID": "",
              "ConnectedService": "INTERNET"
            }
          },
          {
             "c_Internet": {
              "PIID": "7658964",
              "IPv6_Multiple_Path_Needed": ""
            },
            "Test": {
              "PIID": "7658964",
              "INT_Acc_MSP_ID": "",
              "ConnectedService": "INTERNET"
            }
          }
        ]
      }
    }
  }
}

I trued below query but dint work

$..ADD.DIA[?(@.PIID = "1234567")][['c_Internet']]

Thanks in advance.

1 Answer 1

2

you have to use c_Internet.PIID not just PIID

const id="1234567";

$..ADD.DIA[?( @.c_Internet.PIID == id )]["c_Internet"]

result

[
  {
    "PIID": "1234567",
    "IPv6_Multiple_Path_Needed": ""
  }
]
Sign up to request clarification or add additional context in comments.

1 Comment

How can I pass value "1234567" in variable ? this is not working $..ADD.DIA[?(@.c_Internet.PIID == Id )]["c_Internet"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.