# Trouble selecting token from JSON Array

**URL:** <https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759>\
**Category:** Studio\
**Tags:** jsonarray, activities-panel, question, studio, webapi, activities\
**Created:** [January 11, 2025, 8:12pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759 "2025-01-11T20:12:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamiejam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jamiejam/32/121597_2.png) [@jamiejam](https://forum.uipath.com/u/jamiejam)\
**Post date:** [January 11, 2025, 8:12pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/1 "2025-01-11T20:12:45Z")

</div>

Good afternoon UiPath Forum,

I have successfully created a JSON array and can read the tokens. The issue is that each token now has a value under it with its own array. I am at the level I need to be in the JSON data and only want the values at the top highlighted in yellow. When I try to Assign to get the @type, id, or name, I try this but the step returns an ienumerable due to the “size” array of values below it.

ElementType = currentJToken.Values(“@type”).ToString

How can I select @type, id, and name and ignore the “size” part of the token that has its own array (or what steps are needed to deal with them)?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/7/c/87cefd850ee5ce9e9273b1186ac15390fe71e520.png)

---

<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:** [January 11, 2025, 9:10pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/2 "2025-01-11T21:10:13Z")

</div>

> [@jamiejam](#):
>
> The issue is that each token now has a value under it with its own array.

we only see the JObject, but not the JArray. Maybe you can share with us the complete JSON as Textfile

However, we recommend not working with the Values(… as there are more direct approaches for extractions available

---

<div class="post-metadata">

**Author:** ![jamiejam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jamiejam/32/121597_2.png) [@jamiejam](https://forum.uipath.com/u/jamiejam)\
**Post date:** [January 11, 2025, 9:31pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/3 "2025-01-11T21:31:10Z")

</div>

Thanks very much for the fast reply @ppr

Attached is a sample file of the jarray. For each of the tokens, I’m only trying to obtain the @type, id, and name. You’ll see many examples of size, position, or padding that have their own array content under them but I don’t need those. I used Values( because I had worked with it before but I welcome a better way to select within this array. Most appreciated

Jamie  
[jarraysample.txt](https://forum.uipath.com/uploads/short-url/hraHvJTSz74xYBwIYxw7Quk1oOz.txt) (3.6 KB)

---

<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:** [January 11, 2025, 9:53pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/4 "2025-01-11T21:53:45Z")

</div>

A JArray starts with […  
A JOBject starts with {  
we can nest each within others

The JSON is a JArray with JObjects as items and these JOBjects also nest other JOBject for certain Properties as its value

> [@jamiejam](#):
>
> For each of the tokens, I’m only trying to obtain the @type

 ![A screenshot showing a snippet of JSON code and the result of a LINQ expression that selects the "@type" values from the JSON objects into an array. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/a/e/7/ae748d3f28061e46a7eb4286f1d9b8537f814c94.png)

> [@jamiejam](#):
>
> to obtain the @type, id, and name.

Kindly note, that name is not present in every item e.g. id: 31

give a try at the following:

 ![This image depicts a flowchart for processing a JSON array in UiPath, with steps including deserialization, looping through each item, logging specific values, and checking for the presence of the "name" key before logging its value if it exists. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/0/6/8/068ac0101ba67e642f2b32f68cafcc711e7ac0f0.png)

For each | TypeArgument: JOBject

```auto
currentItem = myJArray.Values(Of JObject)

Logs:
currentItem("@type").Value(Of String)
currentItem("id").Value(Of int32)
currentItem("name").Value(Of String)

IF Condition:
currentItem.ContainsKey("name")

```

Logoutput

 ![A list in a graphical interface displaying a hierarchical tree structure with various nodes labeled as PageZone, Header, Body, VTable, Block, Cell, and numerical values. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/f/4/2/f420d68fe925f40d1f193c06854ceb4cb213b5da.png)

---

<div class="post-metadata">

**Author:** ![jamiejam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jamiejam/32/121597_2.png) [@jamiejam](https://forum.uipath.com/u/jamiejam)\
**Post date:** [January 12, 2025, 3:04pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/5 "2025-01-12T15:04:58Z")

</div>

Perfect. I see what I was missing. It looked on the surface I was close, but I really wasn’t. The additional explanation you provided was vital and really helped me learn there, Peter.

Thanks very much @ppr for great feedback!!

---

<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:** [January 15, 2025, 3:05pm UTC](https://forum.uipath.com/t/trouble-selecting-token-from-json-array/814759/6 "2025-01-15T15:05:44Z")

</div>

Closed on January 15, 2025, 3:05pm UTC

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