Search for value in a json using a condition ?

 

Hello community, I want to obtain the value "symbol" using the "id"

Json string:

{
    "positions": [
        {
            "id": "W001",
            "symbol": "US100",
            "volume": 0.10,
            "positions": [
                {
                    "id": "W001",
                    "side": "SELL",
                    "commission": "0.00"
                }
            ]
        },
        {
            "id": "W002",
            "symbol": "BTCUSD",
            "volume": 0.20,            
            "positions": [
                {
                   "id": "W002",
                    "side": "BUY",
                    "commission": "0.00"
                }
            ]
        }
    ]
}

For example

  • find the symbol with id vavlue "id": "W002" ==> "BTCUSD
  • find the symbol with id vavlue "id": "W001" ==> "US100

Any ideas or recommendations on how to do it.


Thanks.