2016-02-15 41 views
-3

該數組的格式如下。我嘗試了一些方法,但我找不到適當的方法。我有一個特殊格式的數組,我想要替換下面顯示的鍵

我想通過AJAX調用發送下面的JSON,但我不想在兩個子數組中使用鍵0,1。

[scheduleDetails] => Array 
    (
     [2] => Array 
      (
       [Wednesday] => Array 
        (
         [0] => Array 
          (
           [startTime] => Array 
            (
             [0] => 00:00 
             [1] => 12:00 
            ) 

          ) 

         [1] => Array 
          (
           [endTime] => Array 
            (
             [0] => 12:00 
             [1] => 07:40 
            ) 

          ) 

        ) 

      ) 
) 

我想是這樣

   [scheduleDetails] => Array 
      (

       [Wednesday] => Array 
        (

           [startTime] => Array 
            (
             [0] => 00:00 
             [1] => 12:00 
            ) 


           [endTime] => Array 
            (
             [0] => 12:00 
             [1] => 07:40 
            ) 



        ) 

      ) 

什麼是該 或jQuery的最佳方法也

 "scheduleDetails":[ 
     {"Friday":[{"startTime":["09:00","15:00"]},{"endTime":["13:00","21:00"]}]}], 

 "scheduleDetails":[ 
     "Friday":["startTime":["09:00","15:00"]},{"endTime":["13:00","21:00"]]], 
+0

謝謝這是我第一次 – krishna

回答

0
"scheduleDetails":[ 
     "Friday":[{"startTime":["09:00","15:00"]},{"endTime":["13:00","21:00"]}]], 

請注意打開和關閉陣列。

[,] -> array object 
{}-> object 
相關問題