# Extract objects from JSON with nested JSON arrays

**URL:** <https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350>\
**Category:** Activities\
**Tags:** jsonarray, json, web, question, webapi, activities\
**Created:** [November 15, 2023, 1:18pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350 "2023-11-15T13:18:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacchr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jacchr/32/176616_2.png) [@jacchr](https://forum.uipath.com/u/jacchr)\
**Post date:** [November 15, 2023, 1:18pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/1 "2023-11-15T13:18:16Z")

</div>

Hi Experts

I have a JSON response looking like this:

```auto
{
    "auditIdg": "cjmifeoijje-jfddsof743-sfjofe837632-dj733i4",
    "familyTree": {
        "cId": 1234567,
        "fullBusinessName": "AJAX INC",
        "affiliateType": "GUP",
        "duns": "012345678",
        "entities": [
            {
                "entity": {
                    "cId": 1111111,
                    "fullBusinessName": "AJAX LTD",
                    "affiliateType": "CS",
                    "duns": "010101010",
                    "entities": [
                        {
                            "entity": {
                                "cId": 2222222,
                                "fullBusinessName": "AJAX Holding",
                                "affiliateType": "CS",
                                "duns": "020202020"
                            }
                        }
                    ]
                }
            },
            {
                "entity": {
                    "cId": 3333333,
                    "fullBusinessName": "Ajax Corp",
                    "affiliateType": "CS",
                    "duns": "030303030"
                }
            },
            {
                "entity": {
                    "cId": 4444444,
                    "fullBusinessName": "AJAX (ES) LTD",
                    "affiliateType": "CS",
                    "duns": "040404040"
                }
            },
            {
                "entity": {
                    "cId": 5555555,
                    "fullBusinessName": "AJAX AB",
                    "affiliateType": "CS",
                    "duns": "050505050",
                    "entities": [
                        {
                            "entity": {
                                "cId": 6666666,
                                "fullBusinessName": "AJAX (SE) AB",
                                "affiliateType": "CS",
                                "duns": "060606060"
                            }
                        },
                        {
                            "entity": {
                                "cId": 777777,
                                "fullBusinessName": "Ajax Holding (SE) AB",
                                "affiliateType": "CS",
                                "duns": "070707070"
                            }
                        },
                        {
                            "entity": {
                                "cId": 8888888,
                                "fullBusinessName": "Ajax Super AB",
                                "affiliateType": "CS",
                                "duns": "080808080"
                            }
                        }
                    ]
                }
            },
            {
                "entity": {
                    "cId": 9999999,
                    "fullBusinessName": "Ajax Sub (AUS)",
                    "affiliateType": "CS",
                    "duns": "090909090"
                }
            }
        ]
    }
}

```

I need to extract all `fullBusinessName` each entity into an array/list of strings. But each entity can contain a sub JSON array with one or more entitites - which again also can contain one or more entities, etc.

How do I extract the required entries? One workaround is to use RegEx but can it not be done with the JSON object itself?

---

<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:** [November 15, 2023, 1:22pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/2 "2023-11-15T13:22:08Z")

</div>

Serialize JSON activity - output myJObject

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/7/8/c/78c9a830183b27776104b44513d7832a49cffc65.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:** [November 15, 2023, 1:41pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/3 "2023-11-15T13:41:19Z")

</div>

Also have a look here:

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/1/2/2/1221de31d5af530eb7bfac62e6c46360bbc3b2dd.png)

---

<div class="post-metadata">

**Author:** ![jacchr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jacchr/32/176616_2.png) [@jacchr](https://forum.uipath.com/u/jacchr)\
**Post date:** [November 15, 2023, 1:43pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/4 "2023-11-15T13:43:15Z")

</div>

Thanks @ppr it was just what I needed - very much appreciated 🙂

---

<div class="post-metadata">

**Author:** ![jacchr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jacchr/32/176616_2.png) [@jacchr](https://forum.uipath.com/u/jacchr)\
**Post date:** [November 16, 2023, 12:02pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/5 "2023-11-16T12:02:06Z")

</div>

Hi @ppr

The solution in outputting to a data table is really great - however I noticed that it skips the first entry (most likely to the filtering out of “entities”).

How do I include the first entity with `"cId": 1234567` and `"fullBusinessName": "AJAX INC"` as well?

---

<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:** [November 16, 2023, 12:10pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/6 "2023-11-16T12:10:09Z")

</div>

> [@jacchr](#):
>
> How do I include the first entity with

add it seperatly similar like the entity

---

<div class="post-metadata">

**Author:** ![jacchr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jacchr/32/176616_2.png) [@jacchr](https://forum.uipath.com/u/jacchr)\
**Post date:** [November 16, 2023, 12:13pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/7 "2023-11-16T12:13:38Z")

</div>

So make multiple Assign activities, or?

---

<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:** [November 16, 2023, 12:59pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/8 "2023-11-16T12:59:37Z")

</div>

assign Activity

JOList | List(Of JObject) =

```auto
(From f In {"..familyTree","..entity"}
From jo In myJObject.SelectTokens(f).Cast(Of JObject)
Let pl = jo.Properties.Where(Function (p) Not p.Name.Equals("entities"))
Select jor = New JObject(pl)).toList

```

Assign Activity  
dtResult = JArray.FromObject(JOList).toObject(Of DataTable)

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/0/2/8/028c619fe410588bf776c33f964470f44909c020.jpeg)

---

<div class="post-metadata">

**Author:** ![jacchr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jacchr/32/176616_2.png) [@jacchr](https://forum.uipath.com/u/jacchr)\
**Post date:** [November 16, 2023, 1:41pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/9 "2023-11-16T13:41:07Z")

</div>

Thanks @ppr that was very helpful

---

<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:** [November 19, 2023, 1:41pm UTC](https://forum.uipath.com/t/extract-objects-from-json-with-nested-json-arrays/698350/10 "2023-11-19T13:41:26Z")

</div>

Closed on November 19, 2023, 1:41pm UTC

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