I'm trying to represent this table using JSON, but do not know what the best way to do. Let's say I have 3 different buckets and I want to group them and show the total number of items by fruit types:
| Orange | Apple | Banana |
----------------------------------------
Bucket 1 | 3 | 4 | 7 |
Bucket 2 | 5 | 6 | 2 |
Bucket 3 | 5 | 11 | 8 |
One way I can think of is this:
{"buckets":
[
{"BucketId":1, "FruitType": "Orange", "Count": 3},
{"BucketId":1, "FruitType": "Apple", "Count": 4},
{"BucketId":1, "FruitType": "Banana", "Count": 7},
{"BucketId":2, "FruitType": "Orange", "Count": 5},
{"BucketId":2, "FruitType": "Apple", "Count": 6},
{"BucketId":2, "FruitType": "Banana", "Count": 11},
{"BucketId":3, "FruitType": "Orange", "Count": 5},
{"BucketId":3, "FruitType": "Apple", "Count": 11},
{"BucketId":3, "FruitType": "Banana", "Count": 8}
]
}
Is there is a better way of respresent in JSON?
Thanks.