DougBreaux 270007SMYJ Visits (8234)
Just a quick note on doing JSON with Spring MVC, under WebSphere 8.5.5 Traditional.
This version of WebSphere includes Jackson 1.6.2 under the covers, for JSON serialization. (Apparently in WebSphere Liberty, the included Jackson isn't available for applications to directly use, but it is in WebSphere Traditional. On Liberty, you have to deploy your own copy of Jackson anyway.)
Spring 4.x "consumes" and "produces" attributes can auto serialize JSON, but apparently only if Jackson 2.x is in the classpath.
Without that, my attempts to send JSON requests resulted in, "415 Unsupported Media Type".
However, because Jackson 1.x and 2.x use different Java packages (org
Quick example of such a Spring controller method, just for reference:
(Assuming, of course, that your request/response classes are annotated with JAXB annotations. And/or Jackson-specific annotations as well, if you need any of those.)
DougBreaux 270007SMYJ Visits (11718)
Minor follow-up to A JS
I needed to seri
Useful search results
In my case, the JSON field in question is named 'properties'. It contains name-value string pairs that I want to get into a Map. Inside my POJO, I define:
private Map<String, String> properties = new HashMap<>();
(See third link above, apparently need to initialize the Map explicitly.)
Then add the following methods, with Jackson-specific annotations:
Then a JSON field like this:
Will be deserialized by the Wink client Resource methods into my Map, to be accessed like this:
String id = myJs
At this version of WebSphere, JAX-RS 1.1 is supported, but that doesn't include any REST Client support. JAX-RS 2.0 apparently does, but that's not yet available here on WAS 8.5.5 Full Profile. It i
Those steps are actually pretty clear and comprehensive. I'll give quick examples of the mostly-default code I used. (Showing full class packages inline, just once, for simplicity.)
Another form of each operation does not throw that Exception, but allows you to manually check the ClientResponse yourself. This is how the example in the above WAS documentation does things. (Note that even those methods do seem to throw Clie
Speaking of POST, here's what that looks like. With a JSON payload as well.
Adding HTTP Basic Authentication
From another WebSphere Knowledge Center article, Secu
JSON Beans and Seri