2016-04-29 211 views
-3

我的目標是這樣的:如何將一個對象轉換爲數組對象?

var response = { 
    "HotelNo": "1", 
    "HCode": "IDGOR_00008", 
    "Name": "Amaris Hotel Gorontalo", 
    "CheckIn": "2016-05-01", 
    "CheckOut": "2016-05-02", 
    "Currency": "IDR", 
    "TotalRate": "380000", 
    "Status": "OR" 
} 

我想改變的對象對象數組像這樣:

var response = [{ 
    "HotelNo": "1", 
    "HCode": "IDGOR_00004", 
    "Name": "Maqna Hotel", 
    "CheckIn": "2016-05-01", 
    "CheckOut": "2016-05-02", 
    "Currency": "IDR", 
    "TotalRate": "582960", 
    "Status": "OK" 
}]; 

任何解決方案來解決我的問題呢?

+0

什麼要實現的目標? – Rajesh

+0

爲什麼一些屬性值在數組中改變一次?至少讓您的示例輸出與示例輸入一致。 – nnnnnn

回答

4

你可以用對象數組

response = [response]; 
+0

我需要你幫忙。看看這裏:http://stackoverflow.com/questions/37209847/how-to-send-parameter-json-array-when-modal-open –

相關問題