|
From: Bill B. <bb...@re...> - 2011-09-09 13:14:54
|
On 9/8/11 3:51 PM, Jeff Schnitzer wrote:
> At least three people on this list (counting myself) have voiced the
> desire to return a simple String to the client from a method, and have
> that String get JSON encoded properly. Right now you cannot construct
> a REST method that returns a simple String without putting JSON
> formatting logic in the Resource, which means I have weird formatting
> logic mixed with my business logic.
>
And I've said I'm not changing Resteasy. Period. There's a few work
arounds for this edge case. For example, just write your own MBW
@Provider
@Produces("application/json", "application/*+json")
public class RawStringJsonWriter implements MessageBodyWriter<String> {...}
Adding this to your environment should override the default
StringTextStar behavior.
> The JSON spec is at the very least ambiguous about how to encode a
> simple String (and boolean and number). Resteasy does the "expected
> thing" with numbers and booleans, I want it to do the "expected thing"
> with strings as well.
>
Your expectations are different than others.
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|