How can I select a value from a JObject using another key-value pair from the same object?

Given the JObject balances, how can I select balance where asset = ‘XBT’?
I am trying to return the value ‘2.2547’.

            'account_id': '123456789', 
            'asset': 'XBT', 
            'balance': '2.2547', 
            'reserved': '0.00', 
            'unconfirmed': '0'
            'account_id': '9123456789', 
            'asset': 'USD', 
            'balance': '200.25', 
            'reserved': '0.00', 
            'unconfirmed': '0'

Thanks in advance

myJObject is the output of the deserialize JSON Activity

As the balance is a JArray we can access the element (JObject) by index:

For filtering to the corresponding JObject Item we can do:

Assign Activity:
myXBTJO | DataType: JObject =
myJObject(“balances”).Where(Function (x) x(“asset”).Value(Of String).Equals(“XBT”)).FirstOrDefault

Then evaluate if myJObject is null or not an retrieve the balance

An optimistic Approach could be:

And will return below, when item is not present

Many thanks @ppr

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