无法读取JSON:无法从字符串值

时间:2015-08-06 06:44:03

标签: java c# json date restsharp

我使用REST SHARP并使用c#代码创建数据 my service is of Java service.

我正在接受转换错误 当我通过CreatedDate = DateTime.Now

Json

{"id":123,"createdDate":"2015-08-06T12:18:32.8405195+05:30"}

C#RestSharp代码

  Customer cust = new Customer()
  cust.id=123;
  cust.createdDate = DateTime.Now;

  string jsonObject = JsonConvert.SerializeObject(cust , new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

  var restClient = new RestClient("http://myurl/");    
  var restRequest = new RestRequest("rest/", Method.POST);    
  restRequest.RequestFormat = DataFormat.Json;
  restRequest.AddParameter("application/json", jsonObject, ParameterType.RequestBody);
  restRequest.AddHeader("Content-Type", "application/json; charset=utf-8");    
  // execute the request
  RestSharp.IRestResponse restResponse = restClient.Execute(restRequest);
  

无法读取JSON:无法构造java.util.Date的实例   字符串值' 2015-08-06T12:13:01.8564244 + 05:30':无效   表示(错误:无法解析日期值   ' 2015-08-06T12:13:01.8564244 + 05:30':无法解析日期   \" 2015-08-06T12:13:01.8564244 + 05:30":与任何   标准形式(\" yyyy-MM-dd' T' HH:mm:ss.SSSZ \",   " yyyy-MM-dd' HH:mm:ss.SSS' Z' \",\" EEE,dd MMM yyyy HH:mm :ss zzz \",   \" yyyy-MM-dd \"))\ n在[来源:   org.apache.catalina.connector.CoyoteInputStream@19198464;行:1,   专栏:69]

0 个答案:

没有答案