# Creating files from json objects

**URL:** <https://discourse.nodered.org/t/creating-files-from-json-objects/59870>\
**Category:** General\
**Created:** [15 March 2022 08:18 UTC](https://discourse.nodered.org/t/creating-files-from-json-objects/59870 "2022-03-15T08:18:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)\
**Post date:** [15 March 2022 08:18 UTC](https://discourse.nodered.org/t/creating-files-from-json-objects/59870/1 "2022-03-15T08:18:16Z")

</div>

Hello everyone. Firstly I'd like to thank members of this community for always helping out when needed. I appreciate it a lot, especially as a new node-red user.

Im trying to create a flow that reads json files that include 2 main objects: accountsList and transactionList.

Each one of the objects have a **dynamic** amount of sub objects.  
For example, accountsList include a number of sub objects that each one represents a bank account, and transactionList represents a list of transactions.

I want to create a file out of every sub-object. i.e a file for each account and each transaction.

This is the the json format-

 ![Screenshot_8](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/121b0d824c0c8a156f598b82b908f6d46e3f5d91.png)

This is the flow structure-

 ![Screenshot_9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/94884294ed1c612dca59e3fb878e7b7c96bc55db.png)

This is the change node-  
 ![Screenshot_10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fcb04a0008493013ac2066f10a345de2b49350a1.png)

In the files that I want to create for each sub-object, i'd like to insert data only from specific fields.  
How can that be possible?

Much thanks for any help!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 08:35 UTC](https://discourse.nodered.org/t/creating-files-from-json-objects/59870/2 "2022-03-15T08:35:58Z")

</div>

If you feed the message into a Change node to move `msg.payload.accountsList` into `msg.payload` and then pass that to a Split node then it will output a message for each account which you can then use to create those files. Separately feed the original message into a Change node and a spilt node to do the same for the transactions.

---

<div class="post-metadata">

**Author:** ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)\
**Post date:** [17 March 2022 06:48 UTC](https://discourse.nodered.org/t/creating-files-from-json-objects/59870/3 "2022-03-17T06:48:06Z")

</div>

Thanks as usual Colin!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 March 2022 06:48 UTC](https://discourse.nodered.org/t/creating-files-from-json-objects/59870/4 "2022-03-31T06:48:29Z")

</div>

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