# Passing string variable to get value from Jobject

**URL:** <https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314>\
**Category:** Studio\
**Tags:** system, webapi, activities\
**Created:** [April 21, 2021, 3:04pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314 "2021-04-21T15:04:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moritz\_Kuehnau](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Moritz\_Kuehnau](https://forum.uipath.com/u/Moritz_Kuehnau)\
**Post date:** [April 21, 2021, 3:04pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/1 "2021-04-21T15:04:53Z")

</div>

Hello fellow automation enthusiasts,  
I am having issues with a propably simple error.

As input i have a .json file.  
I’m using the “Read Text File” activity to read and store it as a String.  
I then, using the “Deserialize JSON” activity, generate a JObject.  
This works. So far, so good.  
Now if i want to select a specific Value from JObject i could use a statement like:  
`Jobject("identifications")(0)("identificationStatus")("status").ToString`  
This also works! Wuhu!

Now comes the part that doesnt work.  
I need to pass (“identifications”)(0)(“identificationStatus”)(“status”) as a string variable.  
For example:

> tmp\_Key = “(”“identifications”“)(0)(”“identificationStatus”“)(”“status”“)”  
> Jobject(tmp\_Key).ToString

This returns the following error message

> RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.

Im assuming it has something to do with not correctly escaping quotes. I’ve fiddled with different ways using " instead of “”. But nothing worked.

I’m grateful for every suggestions on how to fix this.  
Thank you!

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 21, 2021, 3:17pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/2 "2021-04-21T15:17:21Z")

</div>

@Moritz_Kuehnau  
welcome to the forum

`Jobject("identifications")(0)("identificationStatus")("status").ToString`  
navigates through the different elements till the status property

Jobject(“(”“identifications”“)(0)(”“identificationStatus”“)(”“status”“)”) looks fo a long key (which not exists) but is not doing the navigation. Therfore no element is returned

---

<div class="post-metadata">

**Author:** ![Moritz\_Kuehnau](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Moritz\_Kuehnau](https://forum.uipath.com/u/Moritz_Kuehnau)\
**Post date:** [April 21, 2021, 3:32pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/3 "2021-04-21T15:32:37Z")

</div>

Hi Peter,  
thanks for the quick response!  
Is there a way to navigate and retrieve elements using a string variable or am i fighting a loosing battle?

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 21, 2021, 4:14pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/4 "2021-04-21T16:14:29Z")

</div>

@Moritz_Kuehnau  
give a try on working with selectToken:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/3X/8/0/809857425e207de2528cc748a0386fb64d16fcbd.png)

---

<div class="post-metadata">

**Author:** ![Moritz\_Kuehnau](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Moritz\_Kuehnau](https://forum.uipath.com/u/Moritz_Kuehnau)\
**Post date:** [April 28, 2021, 4:15pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/5 "2021-04-28T16:15:03Z")

</div>

Thanks for the hint Peter!  
Using selectToken with the following String

> $.identifications.[0].identificationStatus.status

worked like a charm!  
Thank you for the fast help and have a nice day! =)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [May 1, 2021, 4:15pm UTC](https://forum.uipath.com/t/passing-string-variable-to-get-value-from-jobject/309314/6 "2021-05-01T16:15:44Z")

</div>

Closed on May 1, 2021, 4:15pm UTC

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