How to serialize json object with specific date format ?
json object
{"date": "/Date(-62135596800000)/"}
to string
{"date": "Jan 01,1"}
and i am using extjs as a core library
How to serialize json object with specific date format ?
json object
{"date": "/Date(-62135596800000)/"}
to string
{"date": "Jan 01,1"}
and i am using extjs as a core library
the following code is not finished, but it should give you what you need to achieve your goal. If not, let me know :)
function rxFn(str,m1) {
var d = new Date(parseInt(m1,10));
return <whatever format you wish based on the date object>
}
function fixDateFormat(jsonObject) {
for(var i in jsonObject) {
switch(typeof jsonObject[i]) {
case 'object':
fixDateFormat(jsonObject);
break;
case 'string':
jsonObject[i].replace(/Date\(([0-9]+)\)/,rxFn);
}
}
}
The basic idea is to loop over the json object recursivly and fix all the date serializations you find.
Thanks Martin for your answer As i am using Extjs library so i have modify the code and work perfectly