Skip to content

Commit e0ae39e

Browse files
committed
Add example of arrays within arrays
1 parent c4e7ecc commit e0ae39e

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,95 @@ Repeated rows:
154154
flatten-tool unflatten -f csv examples/array_repeat_rows --main-sheet-name main --root-id='' -o examples/array.json
155155
```
156156

157+
158+
### Arrays within arrays
159+
160+
```
161+
{
162+
"main": [
163+
{
164+
"id": "1",
165+
"d": "6",
166+
"a": [
167+
{
168+
"id": "2",
169+
"b": [
170+
{
171+
"c": "3"
172+
},
173+
{
174+
"c": "3a"
175+
}
176+
]
177+
},
178+
{
179+
"id": "4",
180+
"b": [
181+
{
182+
"c": "5"
183+
},
184+
{
185+
"c": "5a"
186+
}
187+
]
188+
}
189+
]
190+
},
191+
{
192+
"id": "7",
193+
"d": "12",
194+
"a": [
195+
{
196+
"id": "8",
197+
"b": [
198+
{
199+
"c": "9"
200+
},
201+
{
202+
"c": "9a"
203+
}
204+
]
205+
},
206+
{
207+
"id": "10",
208+
"b": [
209+
{
210+
"c": "11"
211+
},
212+
{
213+
"c": "11a"
214+
}
215+
]
216+
}
217+
]
218+
}
219+
]
220+
}
221+
```
222+
223+
|id|d|
224+
|---|---|
225+
|1|6|
226+
|7|12|
227+
228+
|id|a/0/id|
229+
|---|---|
230+
|1|2|
231+
|1|4|
232+
|7|8|
233+
|7|10|
234+
235+
|id|a/0/id|a/0/b/0/c|
236+
|---|---|---|
237+
|1|2|3|
238+
|1|2|3a|
239+
|1|4|5|
240+
|1|4|5a|
241+
|7|8|9|
242+
|7|8|9a|
243+
|7|10|11|
244+
|7|10|11a|
245+
157246
### Why
158247
Imagine a simple dataset that describes grants. Chances are if is to represent the world, it is going to need to contain some one-to-many relationships (.e.g. one grant, many categories). This is structured data.
159248

examples/double_array.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"main": [
3+
{
4+
"id": "1",
5+
"d": "6",
6+
"a": [
7+
{
8+
"id": "2",
9+
"b": [
10+
{
11+
"c": "3"
12+
},
13+
{
14+
"c": "3a"
15+
}
16+
]
17+
},
18+
{
19+
"id": "4",
20+
"b": [
21+
{
22+
"c": "5"
23+
},
24+
{
25+
"c": "5a"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
{
32+
"id": "7",
33+
"d": "12",
34+
"a": [
35+
{
36+
"id": "8",
37+
"b": [
38+
{
39+
"c": "9"
40+
},
41+
{
42+
"c": "9a"
43+
}
44+
]
45+
},
46+
{
47+
"id": "10",
48+
"b": [
49+
{
50+
"c": "11"
51+
},
52+
{
53+
"c": "11a"
54+
}
55+
]
56+
}
57+
]
58+
}
59+
]
60+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
id,a/0/id
2+
1,2
3+
1,4
4+
7,8
5+
7,10
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
id,a/0/id,a/0/b/0/c
2+
1,2,3
3+
1,2,3a
4+
1,4,5
5+
1,4,5a
6+
7,8,9
7+
7,8,9a
8+
7,10,11
9+
7,10,11a
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,d
2+
1,6
3+
7,12

0 commit comments

Comments
 (0)