c# - Read JSON date from file -
i write logs text file json. in file call obejct logtime value
"1378289277591". *{"logtime":"date(1378290565240)"}*
consider code below:
public class sync{ public async task<callmodel> convertcallfiletocallobejct(string path) { try { using (var sr = new streamreader(path)) { string calltext = await sr.readtoendasync(); var call = new javascriptserializer().deserialize<callmodel>(calltext); return call; } } catch (exception exception) { console.writeline(exception.message); } } }
i convert call file call object:
var sync = new sync(); callmodel call = sync.convertcallfiletocallobejct(e.fullpath).getawaiter().getresult();
the problem call.logtime
9/4/2013 10:29:25 am using chrome console , new date(1378290565240) result 9/4/2013 14:59:25 pm
what problem?
try below code
// json received server in string format var jsonstring = '{"date":1251877601000}'; //use json2 or js library parse string var jsonobject = json.parse( jsonstring ); //now have date! alert( new date(jsonobject.date) );
Comments
Post a Comment