こんばんは、セッションストレージからデータを取得してJSON形式にしたいのですが、配列になっている"productid"と"quantity"に複数の値をいれる方法がわかりません。
形としては [{
"productid": list.productid,
"quantity": list.quantity
},
{
"productid": list.productid,
"quantity": list.quantity
}]
配列の中に複数の値を持てるようしたいです。
お力添えいただけるとうれしいです。
以下セッションストレージ _________________________________________________________________ cart json [ { "id": "1", "manufacture": "mont-bell", "price": "10000", "quantity": 2, "title": "パーカー" }, { "id": "3", "manufacture": "Marmot", "price": "13924", "quantity": 1, "title": "ジャケット" }, { "id": "4", "manufacture": "THE", "price": "3856", "quantity": 1, "title": "S/S" } ] user json { "user_id": "2", "user_name": "hoge", "user_zip_code": "231-8359" } subtotal 37780 以下javascript ____________________________________________________________________ $(document).ready(function() { $(document).on('click',"#completion",function(){ alert("kurikku") var user = JSON.parse(sessionStorage.getItem("user")); var list = JSON.parse(sessionStorage.getItem("cart")); var subtotal = sessionStorage.getItem("subtotal"); var users = { "userid": user.user_id, "subtotal": subtotal, "products": [ { "productid": list[i].productid, "quantity": list[i].quantity } ] }
回答1件
あなたの回答
tips
プレビュー