# Fill table with text from json

**URL:** <https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020>\
**Category:** InDesign\
**Tags:** uxp, javascript\
**Created:** [October 24, 2023, 8:52pm UTC](https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020 "2023-10-24T20:52:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KDJFS](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kdjfs/32/3297_2.png) [@KDJFS](https://forums.creativeclouddeveloper.com/u/KDJFS)\
**Post date:** [October 24, 2023, 8:52pm UTC](https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020/1 "2023-10-24T20:52:21Z")

</div>

Hi,  
I have a json from an api and want to create from this a table.  
I have created my table with the corresponding cells. But I have now the problem to fill the table wit text. If I try to iterate over the cells, rows or columns i have everytime the problem that I can’t iterate because its a object. Also something like `myTable.cell[2]` doesn’t work to select the second cell or column etc.  
Is there any best practise to fill the table with text?

Cheers

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [October 24, 2023, 10:04pm UTC](https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020/2 "2023-10-24T22:04:33Z")

</div>

Gonna need to see code examples to help here; although it sounds like a vanilla JS issue rather than UXP.

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [October 24, 2023, 11:55pm UTC](https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020/3 "2023-10-24T23:55:14Z")

</div>

You are talking about the InDesign DOM, not JSON, correct?

Most InDesign objects are probably XPath or something based objects, not iterable. To make it easier to iterate, change them to static array like this. Then you can use map, filter, and other useful features.

```auto
const cellsArray = myTable.cells.everyItem().getElements() ;

```

I expect that `myTable.cell[2]` would work if changed as follows.

```auto
myTable.cells[2] ; // cell **s**

```

---

<div class="post-metadata">

**Author:** ![KDJFS](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kdjfs/32/3297_2.png) [@KDJFS](https://forums.creativeclouddeveloper.com/u/KDJFS)\
**Post date:** [October 25, 2023, 1:30am UTC](https://forums.creativeclouddeveloper.com/t/fill-table-with-text-from-json/7020/4 "2023-10-25T01:30:48Z")

</div>

@sttk3 thanks your code with

```javascript
.everyItem().getElements()

```

makes it really easier.  
Oh man I hate theese dumb mistakes like missing the plural s 😃 .

@Timothy_Bennett your right it seems the vanilla js solution from sttk3 makes easier for me.
