Can Jackson be configured to trim leading/trailing whitespace from all string properties?

Example JSON (note that the string has trailing spaces): { “aNumber”: 0, “aString”: “string ” } Ideally, the deserialised instance would have an aString property with a value of “string” (i.e. without trailing spaces). This seems like something that is probably supported but I can’t find it (e.g. in DeserializationConfig.Feature). We’re using Spring MVC 3.x … Read more

json_encode(): Invalid UTF-8 sequence in argument

I’m calling json_encode() on data that comes from a MySQL database with utf8_general_ci collation. The problem is that some rows have weird data which I can’t clean. For example symbol �, so once it reaches json_encode(), it fails with json_encode(): Invalid UTF-8 sequence in argument. I’ve tried utf8_encode() and utf8_decode(), even with mb_check_encoding() but it … Read more

Javascript long integer

I have seen one of the weirdest things in javascript. The server side (spring): @RequestMapping(value = “/foo”, method = RequestMethod.GET) @ResponseBody public Long foo() { return 793548328091516928L; } I return a single long value and: $.get(‘/foo’).done(function(data){ console.log(data); }); It represents the long integer as “793548328091516900” replacing (rounding indeed) the last two digits with 0s. When … Read more

How do I compress a Json result from ASP.NET MVC with IIS 7.5

I’m having difficulty making IIS 7 correctly compress a Json result from ASP.NET MVC. I’ve enabled static and dynamic compression in IIS. I can verify with Fiddler that normal text/html and similar records are compressed. Viewing the request, the accept-encoding gzip header is present. The response has the mimetype “application/json”, but is not compressed. I’ve … Read more

How to define Typescript Map of key value pair. where key is a number and value is an array of objects

In my angular2 app i want to create a map which takes a number as key and returns an array of objects. I am currently implementing in following way but no luck. How should i implement it or should i use some other data structure for this purpose? I want to use map because maybe … Read more

Deserialize JSON / NSDictionary to Swift objects

Is there a way to properly deserialize a JSON response to Swift objects resp. using DTOs as containers for fixed JSON APIs? Something similar to or something like this example from Java User user = jsonResponse.readEntity(User.class); whereby jsonResponse.toString() is something like { “name”: “myUser”, “email”: “”, “password”: “passwordHash” } Answer SWIFT 4 Update Since … Read more