serialize date json to java date

I created an asp.net web service asmx json return data type. I want to read java json data on the web server.

result :{"loaiChungTu":"PC","soChungTu":48048048000000000,"ngayHieuLuc":"/Date(1452445200000)/"}

[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetChungtuById(String loai, decimal sochungtu) {     string sql = "SELECT * FROM Chungtu where loaichungtu = '" + loai + "' and Sochungtu = " + sochungtu;     SqlConnection sqlConnection1 = new SqlConnection(connect);     SqlCommand cmd = new SqlCommand();     SqlDataReader reader;      cmd.CommandText = sql;     cmd.CommandType = CommandType.Text;     cmd.Connection = sqlConnection1;      sqlConnection1.Open();     reader = cmd.ExecuteReader();       ChungTuBulkCopy item = new ChungTuBulkCopy();     ChungTuBulkCopyId id = new ChungTuBulkCopyId();     while (reader.Read())     {         id.loaiChungTu = reader[0].ToString();         id.soChungTu = long.Parse(reader[1].ToString());         item.hoTen = reader[2].ToString();         item.boPhan = reader[3].ToString();         item.ngayLap = DateTime.Parse(reader[4].ToString());         item.maNguoiLap = reader[5].ToString();         item.soCtkeToan = reader[6].ToString();         id.ngayHieuLuc = DateTime.Parse(reader[7].ToString());         item.trungGian = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";         item.dienGiai = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";         item.id = id;     }     reader.Close();     sqlConnection1.Close();     return  new JavaScriptSerializer().Serialize(id);       //HttpContext.Current.Response.Write(json); }  <script type="text/javascript" language="javascript">      function callPost(rs) {         //alert(rs);         $.ajax({              url: 'http://localhost:8080/admin-frontend/remoting/data/chungtuObj',              type: 'POST',              dataType: 'json',              data: rs,              contentType: 'application/json',             mimeType: 'json',             success: function(data) {                  alert(data);             },             error:function(data,status,er) {                  alert("error: "+data+" status: "+status+" er:"+er);             }         });     }         $(function () {         $('#btnCallService').click(function () {             $.ajax({                 type: 'POST',                 url: 'http://10.1.3.159:8003/ChungtuService.asmx/GetChungtuById',                 data:"{loai:'PC',sochungtu:48048048000000000}",                 dataType: 'json',                 contentType: 'application/json; charset=utf-8',                 success: function (data) {                     //var array  = JSON.stringify(data.id);                     $('#lblData').html(data.d);                     //document.write(array);                     callPost(JSON.stringify(JSON.parse(data.d)));                 },                 error: function (error) {                     console.log(error);                 }             });         });     }); </script>  @RequestMapping(value = "/chungtu", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public @ResponseBody ChungTuBulkCopyId postChungtu(@RequestBody final ChungTuBulkCopyId test,         ModelMap model) {     System.out.println(test);     return test; }  @RequestMapping(value = "/chungtuObj", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public @ResponseBody Object postChungtuObj(@RequestBody final Object test, ModelMap model) {     ObjectMapper mapper = new ObjectMapper();     try {         mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,                 true);         ChungTuBulkCopyId staff1 = mapper.readValue(test.toString(),                 ChungTuBulkCopyId.class);         System.out.println(staff1);     } catch (JsonGenerationException e) {         e.printStackTrace();     } catch (JsonMappingException e) {         e.printStackTrace();     } catch (IOException e) {         e.printStackTrace();     }     return test; } 

com.fasterxml.jackson.core.JsonParseException: Unexpected character ('l' (code 108)): was expecting double-quote to start field name at [Source: {loaiChungTu=PC, soChungTu=48048048000000000, ngayHieuLuc=/Date(1452445200000)/}; line: 1, column: 3] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1586) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:521) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:450) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1701) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:642) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2797) at com.evnit.fmis.web.services.JSONController.postChungtuObj(JSONController.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606)

Replay

Category: java Time: 2016-07-30 Views: 3
Tags: java json date asmx

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.304 (s). 12 q(s)