を作成し、私はこの例のようにalasqlに戻るには、これらの値にループを作成する必要があります。私は、これらの値を持つ配列を持つforeachのJavaScriptでオブジェクト配列
http://jsfiddle.net/agershun/11gd86nx/5/
var data = {
"business": [
{
"order_contents": [
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 85,
"name": "product 3",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 84,
"name": "product 2",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 83,
"name": "product 1",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
},
{
"id": 84,
"name": "product 2",
"price": "1.99",
"quantity": 1,
"total": "1.99",
"ingredients": [],
"extras": []
}
]
}
]
};
ここに私のコードです。 。
info.orderByChild("data").startAt("08/04/2017").endAt("12/06/2017").on('value', function(snapshot){
snapshot.forEach(function(item) {
jsonObj = {
"business": [
{
"order_contents": [
{
"id": itemVal['id'],
"name": itemVal['name'],
"price": itemVal['price'],
"quantity": itemVal['quantity'],
"total": "itemVal['total']
}
]
}
]
}
そのない配列を作成し、最後の値だけ..
誰かが私を助けることができますか?
は、そのようにタグ付けして下さい。 –
ok、そのタグ付き!ありがとう – sealabr
各反復で同じ変数( 'jsonObj')を上書きしているので、最後の項目で終わるのです。あなたは 'jsonObj'をどこで定義し、それを何のために使っていますか? –