<script type="text/javascript">
            $(window).load(function () {
                var data = {};
                data.import_order_id = $("#hf_txnID").val();
                data.firstname = $("#hf_Fname").val();
                data.lastname = $("#hf_Lname").val();
                data.email = "albert.pinto@xyz.com";
                data.company = "";
                data.address_1 = "Address Line 1";
                data.address_2 = "Address Line 2";
                data.city = "Shipment City";
                data.postcode = " Shipment Postcode";
                data.state = " Shipment State ";
                data.country_code = "IN";
                data.telephone = "98XXXXXXXX";
                data.mobile = "98XXXXXXXX";
                data.payment_method = " Payment Method";
                data.payment_code = "Payment Code";
                data.shipping_method = "Shipment Method";
                data.order_status_id = "1";
                alert(data.country_code);
                var produrcts = [];
                $.ajax({
                    type: "post",
                    url: "http://api.kartrocket.co/index.php?route=feed/web_api/addorder&key=APITEST;",
                    data: JSON.stringify(data),
                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                        return true;
                    },
                  
                    failure: function (data) { alert("Something Went Wrong!!! Try Again Later"); },
                    error: function (data) { alert("Something Went Wrong!!! Try Again Later"); }
                });
            });
        </script>
this is the code which i am using to implement kartrocket api.
i want to add sub array within the products variable automatically.
below is the example 
 
so anyone please tell me how can this possible for me.
"products":[
      {
         "name":"Apple iPhone 4Sx",
         "model":"MB0010",
         "sku":"MB0010",
         "quantity":1,
         "subtract":1,
         "price":145,
         "total":145,
         "tax":6.9047619047619,
         "reward":0
      },
      {
         "name":"Apple iPhone 4C",
         "model":"MB0011",
         "sku":"MB0011",
         "quantity":1,
         "subtract":1,
         "price":145,
         "total":145,
         "tax":6.9047619047619,
         "reward":0
      }
   ],
 "totals":{
      "handling":44,
      "low_order_fee":77,
      "sub_total":145,
      "tax":7,
      "total":266
   },
   "weight":1,
   "weight_unit":"kg",   #Accepted Values : kg,g 
   "comment":"",
   "total":266
}