我正在使用jasper服务器和mongodb创建报告。我的json如下:
{
"_index": "spot",
"_type": "events",
"_id": "AVNVuep8N5qpVGQABmT3",
"_score": null,
"_source": {
"eventType": "kioskTransaction",
"messageType": "event",
"version": "1",
"timestamp": 1457432194130,
**"data": {
"amount": 4,
"products": [
{
"bin": "6",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "3",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "4",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "CP1",
"quantity_units": "CUP",
"quantity": 1
}
],**
"payments": [
{
"last_four": "9142",
"expiration_date": "0000",
"troutd": "1410045878",
"card_type": "Visa",
"amount": 4,
"invoice": "CM00006399",
"type": "credit_card"
}
],
"language": "English"
},
"tzoffset": -8,
"spotId": "SSN-CK-0332",
"org": "/root/ssn/candyfactory",
"spotTimestamp": 1457403713474,
"spotTimezone": -8
},
"fields": {
"spotTimestamp": [
1457403713474
],
"timestamp": [
1457432194130
]
},
"sort": [
"kiosktransaction"
]
}
当我尝试获取data.products
时,我会得到如下列表:
{
"bin": "6",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "3",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "4",
"quantity_units": "Oz",
"quantity": 2
},
{
"bin": "CP1",
"quantity_units": "CUP",
"quantity": 1
}
但是在不计算机中没有可用的选项来计算每个箱子中的数量。如果你知道的话,请帮助我,因为我被卡住了。