简体   繁体   中英

How to get exactly time when parse json

I have Json with item like below:

{
 "Id": 3355211,
 "TimeStamp": "2018-08-13T00:16:06.47",
}

I want access TimeStamp so I call

   string _time= item.TimeStamp;

So _time return {8/13/2018 12:16:06 AM} . I want get exactly 2018-08-13T00:16:06.47 . How can I do that ?

Below is the sample code and using Newtonsoft.Json

void Main()
{
   var s = "{ \"Id\": 3355211, \"TimeStamp\": \"2018-08-13T00:16:06.47\", }";
   JsonConvert.DeserializeObject<JsonClass>(s).Dump();
 }
public class JsonClass{
  public int Id { get; set; }
  public string TimeStamp { get; set; }
}

And the output will look like,

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM