# I want to combine two JSON datasets in a flow

**URL:** <https://community.postman.com/t/i-want-to-combine-two-json-datasets-in-a-flow/73630>\
**Category:** Help Hub\
**Tags:** postman-flows, evaluate-block\
**Created:** [January 10, 2025, 12:53pm UTC](https://community.postman.com/t/i-want-to-combine-two-json-datasets-in-a-flow/73630 "2025-01-10T12:53:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![advectus1974](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@advectus1974](https://community.postman.com/u/advectus1974)\
**Post date:** [January 10, 2025, 12:53pm UTC](https://community.postman.com/t/i-want-to-combine-two-json-datasets-in-a-flow/73630/1 "2025-01-10T12:53:38Z")

</div>

I’m trying to amalgamate two JSON data sets in a flow. I have outlined below an example of what I need to achieve.

Data set 1 (clients)

```auto
[
{
“Id”: “ABCD”,
“Department”: “C1000”,
“status”: “Active”
},
{
“Id”: “BCDE”,
“Department”: “C2000”,
“status”: “Active”
},
{
“Id”: “CDEF”,
“Department”: “C4000”,
“status”: “Active”
}
]

```

Data set 2 (Jobs)

```auto
[
{
“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “12345”
},
{
“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “14765”

},
{
“jobclient”: “ABCD”,
“jobdept”: “C6000”,
“key”: “1275”
},

{

“jobclient”: “CDEF”,
“jobdept”: “C6000”,
“key”: “2345”

},

{

“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “182245”

}

]

```

Required output would be a ….

```auto
[

{

“Id”: “ABCD”,
“Department”: “C1000”,
“status”: “Active”,
“jobclient”: “ABCD”,
“jobdept”: “C6000”,
“key”: “1275”

},

{

“Id”: “BCDE”,
“Department”: “C2000”,
“status”: “Active”,

“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “12345”

},

{

“Id”: “BCDE”,
“Department”: “C2000”,
“status”: “Active”,

“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “14765”

},

{

“Id”: “BCDE”,
“Department”: “C2000”,
“status”: “Active”,

“jobclient”: “BCDE”,
“jobdept”: “C6000”,
“key”: “182245”

},

{

“Id”: “CDEF”,
“Department”: “C4000”,
“status”: “Active”,
“jobclient”: “CDEF”,
“jobdept”: “C6000”,
“key”: “2345”

}

]

```

The output needs to run through the client dataset and create a record for each time it finds a match in the jobs dataset.

I’m sure it will require an “Evaluate” block and use the $map function but I have no idea how to write it. Can anyone help?

---

<div class="post-metadata">

**Author:** ![flows-daniel](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/flows-daniel/32/25516_2.png) [@flows-daniel](https://community.postman.com/u/flows-daniel)\
**Post date:** [January 24, 2025, 11:30pm UTC](https://community.postman.com/t/i-want-to-combine-two-json-datasets-in-a-flow/73630/2 "2025-01-24T23:30:33Z")

</div>

Hi @advectus1974

This can be done in an evaluate block and you can even use Postbot to help you generate the TypeScript code to do it!

Try this solution and adjust as needed:

```auto
jobs.map(job => {
    const matchingClient = clients.find(client => client.Id === job.jobclient);

    if (matchingClient) {
        return { ...matchingClient, ...job };
    }
    return null; // Optional: handle case where no matching client is found
}).filter(Boolean);

```

I named your first json clients and second json jobs in the evaluate block to get this result:

 ![Screenshot 2025-01-24 at 3.28.26 PM](https://us1.discourse-cdn.com/getpostman/original/3X/9/9/9982ebb9a241f51ddecf76d8df0b540175719035.png)

Let me know if you run into any issues.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [April 24, 2025, 11:31pm UTC](https://community.postman.com/t/i-want-to-combine-two-json-datasets-in-a-flow/73630/3 "2025-04-24T23:31:09Z")

</div>

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