Passing Dynamic value to datatable to access the value inside Nested JSON

I have a nested json that looks like below:

image

I am trying to access the value inside the JSON array “OU”, by passing dynamic values to the datatable, such that I get the value as OU1, OU2 or so based on the value I pass. Let me explain with the code snippet below:

I have a JSON object jsonConfig which holds the values of JSON file. I am trying to access the nested JSON as below:

jsonConfig(“OU”).Item(0).Item(“NALA”).ToString

This prints the value as “OU1”. I have another datatable dtRegion which holds the region info.

Region


NALA
EMEA
APAC

I am passing this to the as below:

Config(“OU”).Item(0).Item(row(0)).ToString

This fails. I am passing an object only but still fails to print with below error:

image

@ArvindMR
Welcome to the forum
in case of you want with the row(0) value access the JSON give a try on

Config(“OU”).Item(0).Item(row(0).toString.Trim).ToString

Thanks @ppr ! Missed to mention that initially, yes I tried that as well but with no luck.

please share with the a screenshot / details of the Assign activity throwing this exception.
Also do a debugging along with breakpoints and do also some stepwise debuggings. Inspect the variable to find out when it breaks when the expected value is null

Below is the assign activity used [same as what I mentioned in the writeline].

image

I did debug and it expects an Object. I suppose row(0) from a datatable is an object as well. But still fails.

image

In simple, I am looking pass a dynamic value to get the value from nested JSON. If there are any other better alternatives, please share as well.

Have a look below on what did work and on how we can use debugging and immediate panel for prototyping /explorations:

1 Like

Thanks @ppr ! This is useful. However, when I try the same from my end, it gives me the below:

image