0
我有一個JSON輸入。我想將所有時間戳(createdDate,modifiedDate)轉換爲ruby中的時間。我怎麼做?我嘗試下面的方法,但憑着工作Ruby:在給定的json輸入中將時間戳轉換爲日期時間
characterList.each { |char| DateTime.strptime(char.try(:getEditInfo).try(:getCreatedDate),%s) }
{"characterList":
[
{"editInfo":
{"createdBy": "testname",
"createdDate": 1503137795000,
"modifiedBy": "testname",
"modifiedDate": 1503137795000},
"charInfo":
{"charid": "3434",
"charDesc": "3434",
"status": "ON"}
},
{"editInfo":
{"createdBy": "testname",
"createdDate": 1503137795000,
"modifiedBy": "testname",
"modifiedDate": 1503137795000},
"charInfo":
{"charid": "3434 6",
"charDesc": "43dfdf",
"status": "ON"}
},
{"editInfo":
{"createdBy": "testname",
"createdDate": 1503137795000,
"modifiedBy": "testname",
"modifiedDate": 1503137795000},
"charInfo":
{"charid": "4hr_SLA",
"charDesc": "sd",
"status": "ON"}
},
{"editInfo":
{"createdBy": "testname",
"createdDate": 1503137795000,
"modifiedBy": "testname",
"modifiedDate": 1503137795000},
"charInfo":
{"charid": "aaaaaaaaaa",
"charDesc": "asdfaadsf asdfasdf asdf",
"status": "ON"}
},
{"editInfo":
{"createdBy": "testname",
"createdDate": 1503137795000,
"modifiedBy": "testname",
"modifiedDate": 1503137795000},
"charInfo":
{"charid": "abababab",
"charDesc": "abababababab",
"status": "ON"}
}
]}
我行分別爲createdDate和modifiedDate 2轉換等。但是我在尋找一個在線解決方案