How do I grab the values from this JSON structure?

How would I reference the key value for item 1 under the revenue section (4 in this example) from the following structure?

"totalPercents": [
    {
      "sourceName": "REVENUE",
      "percents": [
        {
          "key": "Item 1",
          "value": 4
        },
        {
          "key": "Item 2",
          "value": 8
        }
      ]
    },
    {
      "sourceName": "EXPENSES",
      "percents": [
        {
          "key": "Item 1",
          "value": 2
        },
        {
          "key": "Item 2",
          "value": 4
        }      ]    }  ]
1 Like

Total percent’s first item’s percent’s first item’s value should work

2 Likes

Yes, I think I will have to go with this approach.

I was concerned that the ordering might change as I am building an accounting / balance sheet type of table and the API has been in development. I was using filtering to grab the exact item strings but will probably worry about that another day.

Thanks for taking a look!

1 Like

If you don’t know which item in the list it is, then you can just use a filter to find it based on some other known value.

1 Like

Yes. I was having trouble nesting the filters. I could filter for value 1 but couldn’t figure out how to use a filter to grab the second level of info… it didn’t seem like it was going to work after trying quite a few variations before posting.

Currently using this string to make it work:
Total percent’s item# x percent’s item# x value -
Total percent’s item# x percent’s item# x key

The developer put them out of order they show on the page, thus I am matching the rows up by outputting the key to ensure I am placing the values on the right line. Unsure if this solution will hold, but if not, I will add a filter to Total percent’s item# x percent's:filtered by key=arbitrary text - first item: value to the end of the expression to ensure it. Hoping that the first part of the sequence is hard coded. Either way, they aren’t deal breaker values but it is an interesting look at how to build the expressions. Thanks again for your help.

Edit: Just found the items shift from one record to the next (by using the first method). Shifting to the solution of selecting the item first, then using the filter.

1 Like