Arrays in items.add?

Is it possible to add arrays within an items.add loop? Eg something along the lines of:

JS

for(var i=0,len=data.val.length;i<len;i++){
items.add({
id:data.val[i].id,
oranges[0]:data.val[i].orange1,
oranges[1]:data.val[i].orange2,
oranges[2]:data.val[i].orange3,
})
}

.UX

<Each Items="{items}">
<Each Items="{oranges}">
<Text Value="{oranges[1]}" />

Yes, adding arrays within objects is generally okay, although the syntax is different from what you’re showing here.

{oranges: ["one", "two", "three"]}

Exactly how you craft that object and nested arrays is totally up to you, and it’s a JavaScript thing.

What’s the real question though? Could you post a complete, minimal example of what you’ve tried to do and what didn’t work?

Thanks.

Still learning and sandboxing. Basically trying to understand best ways of using each when importing json files, but got stuck when trying to figure out how to deal with arrays, so for above example modified:

for(var i=0,len=data.val.length;i<len;i++){
items.add({
id:data.val[i].id,
oranges:[data.val[i].orange1,data.val[i].orange2,data.val[i].orange3]
})
}

Then iterating the items and within items iterate its arrays:

<Each Items="{items}">
<Text Value="{id}" />
<Each Items="{oranges}"> ???
<Text Value="{oranges[1]}" /> ???
</Each>
</Each>

Clearly the ??? lines is a wrong approach.

I still don’t see the complete example, and I don’t really see any specific question either. Here you go then, this is what a bucket with 3 boxes and a variable amount of fruits inside them looks like in Fuse, using vanilla JS objects and arrays:

<App>
	<JavaScript>
		var types = [
			{title: "orange", count: 4},
			{title: "apple", count: 3},
			{title: "pear", count: 5}
		];

		var bucket = [];
		types.forEach(function(t) {
			var box = {type: t.title + "s", fruits: []};
			for (var i = 0; i < t.count; i++) {
				box.fruits.push(t.title + " " + (i + 1));
			}
			bucket.push(box);
		});

		module.exports = {
			bucket: bucket
		};
	</JavaScript>
	<StackPanel Margin="4" ItemSpacing="4">
		<Each Items="{bucket}">
			<StackPanel ItemSpacing="2">
				<Text Value="{type}" Background="#ccc" />
				<Each Items="{fruits}">
					<Text Value="{}" />
				</Each>
			</StackPanel>
		</Each>
	</StackPanel>
</App>