Parsing JSON DateTime from Newtonsoft’s JSON Serializer

Use one of the JsonConverters that come with Json.NET for working with dates to get a better format. JavaScriptDateTimeConverter will automatically give you a JavaScript date. public class LogEntry { public string Details { get; set; } public DateTime LogDate { get; set; } } [Test] public void WriteJsonDates() { LogEntry entry = new LogEntry … Read more

jQuery AJAX request failing in IE

Fixed, I changed the content-type from application/json; charset=utf8 to just plain application/json. I hate IE 🙂 Also to avoid IE super-caching try this: var d = new Date(); $.ajax({ url:”{{SITE_URL}}/content/twitter.json?_=”+d.getTime(), …Snip… That way each request is a new url for IE to get 😀

How can I decode JWT (JSON web token) token in Swift?

If you are okay with using a library i would suggest this and then import the library import JWTDecode and execute. let jwt = try decode(jwt: token) Since you didn’t want to include this library i brought out the needed parts to make it work. func decode(jwtToken jwt: String) -> [String: Any] { let … Read more

IE tries to download json response while submitting jQuery multipart form data containing file

You can simply return JSON from the controller as “text/html” and then parse it on the client side using JQuery.parseJSON(). Controller: return this.Json( new { prop1 = 5, prop2 = 10 }, “text/html”); Client side: jsonResponse = $.parseJSON(response); if(jsonResponse.prop1==5) { … } This solution has been working for me.

Is there a method built in spring MockMVC to get json content as Object?

As far as I know MockHttpServletResponse (Unlike RestTemplate) doesn’t have any method which could convert returned JSON to a particular type. So what you could do is use Jackson ObjectMapper to convert JSON string to a particular type Something like this String json = rt.getResponse().getContentAsString(); SomeClass someClass = new ObjectMapper().readValue(json, SomeClass.class); This will give you … Read more