|
From: Matthew G. <mat...@gm...> - 2011-09-08 11:43:46
|
Hi Jeff, I assume that the "edge case" in question is that a plain string is not considered to be valid json. Certainly jslint does not think so, and it having been written by Crockford I would assume it is correct. You can check yourself at http://jslint.com/ by comparing the output given for "hello" (invalid) and {"string":"hello"} (JSON: good). The rfc for application/json (http://www.ietf.org/rfc/rfc4627.txt) states that JSON text must be an object or an array, which are fully defined at http://json.org/. FWIW, my company uses RestEasy and Jackson without much problem and I'm sure there are lots of others that do. Matthew On Thu, Sep 8, 2011 at 9:33 AM, Jeff Schnitzer <je...@in...> wrote: > I tried replacing @Produces("*/*") on StringTextStar with > @Produces("text/*"), which seemed to have the right effect - the > jackson provider gets called to handle the string. > > Unfortunately this just slams my head into the next roadblock, which > is that the JacksonJsonProvider explicitly refuses to handle String > with the cryptic comment "24-Apr-2009, tatu: String is an edge case... > let's leave it out". WTF? > > I'd like to ask about this on the Jackson mailing list but all links > to it seem to be 404. Codehaus has always felt like a trainwreck but > seriously, it's time to move that project to Github or Google Code... > which I would love to suggest if I could find the mailing list. > > I could hack/extend ResteasyJacksonProvider to explicitly re-enable > Strings again, but this seems to be getting out of hand. Ugh. Here's > a point of confusion I'll need to resolve if I go this route - how > does Resteasy know to use ResteasyJacksonProvider instead of > JacksonJsonProvider? > > I'm totally baffled that there aren't hundreds of engineers screaming > about this problem. My growing fear is that there aren't hundreds of > engineers using these tools. They've all moved on to > Ruby/Node.js/whatever. > > Moment of inspiration - I could just create my own MessageBodyWriter > that @Produces("application/json") for String and uses the > ObjectMapper to spit out json myself. How do I ensure that mine gets > placed ahead of ResteasyJacksonProvider? (and, for that matter, > StringTextStar if I decide to return it to stock) > > Thanks, > Jeff > > > On Thu, Sep 8, 2011 at 12:42 AM, Morch, Holger <hol...@na...> wrote: >> Hi Jeff, >> >> I have the same issue. I think the idea is that if you return a string RESTeasy expects that it is in the correct format (json, xml or whatever). I don't know why this is the case. >> For me one solution would be to exclude StringTextStar provider from registry. I don't want to disable automatic discovery of providers completely but just exclude this provider. If the Jackson provider would be used, the response would be correct. >> >> Kind regards, >> Holger >> >> -----Original Message----- >> From: Jeff Schnitzer [mailto:je...@in...] >> Sent: Donnerstag, 8. September 2011 09:18 >> To: res...@li... >> Subject: Re: [Resteasy-developers] java.lang.String JSON formated >> >> After a few minutes with the debugger, yeah, looks like the problem is that StringTextStar is being chosen. It's just ahead of ResteasyJacksonProvider in the priority list. This seems odd. >> >> Could this have something to do with StringTextStar having @Produces("*/*")? Shouldn't this be @Produces("text/*")? It certainly can't produce application/json. >> >> Jeff >> >> >> On Thu, Sep 8, 2011 at 12:00 AM, Jeff Schnitzer <je...@in...> wrote: >>> Looks like someone else has this problem, but no response. I looked >>> at the headers and I'm getting back application/json as the >>> content-type, but no quotes. >>> >>> Should I log this as a bug? Any workaround short of wrapping all >>> strings in another object? >>> >>> Jeff >>> >>> On Wed, Feb 9, 2011 at 5:02 AM, Morch, Holger <hol...@na...> wrote: >>>> Hello, >>>> >>>> >>>> >>>> I’ve a Method which returns just a Sting. The @Produces mime types >>>> are {"application/*+json", "application/json", "text/json"} but if >>>> one requests the data he gets only the String which is returned by >>>> the Method. Correct JSON format would be a quoted string (http://www.json.org/ Section: >>>> string). >>>> >>>> Example: >>>> Method return value: Test >>>> >>>> HTTP Content: Test >>>> >>>> Expected Content: “Test” >>>> >>>> >>>> >>>> I’m using Jackson as JSON Provider and I think he would format it correctly. >>>> Unfortunately the StringTextStar MessageBodyWriter is chosen instead >>>> of Jackson. I saw that you’re sorting the MessageBodyWirters somehow >>>> and I’m sure you have good reasons to sort this way. Is there a way >>>> to get Jackson as MessageBodyWriter in this case? How can I do that? >>>> >>>> >>>> >>>> Kind regards >>>> >>>> Holger >>>> >>>> >>>> >>>> ------------------------------------------- >>>> >>>> >>>> >>>> Holger Morch >>>> Software Engineer >>>> >>>> NAVTEQ Germany GmbH & Co.KG >>>> >>>> >>>> >>>> ________________________________ >>>> The information contained in this communication may be CONFIDENTIAL >>>> and is intended only for the use of the recipient(s) named above. If >>>> you are not the intended recipient, you are hereby notified that any >>>> dissemination, distribution, or copying of this communication, or any >>>> of its contents, is strictly prohibited. If you have received this >>>> communication in error, please notify the sender and delete/destroy >>>> the original message and any copy of it from your computer or paper files. >>>> >>>> --------------------------------------------------------------------- >>>> --------- The ultimate all-in-one performance toolkit: Intel(R) >>>> Parallel Studio XE: >>>> Pinpoint memory and threading errors before they happen. >>>> Find and fix more than 250 security defects in the development cycle. >>>> Locate bottlenecks in serial and parallel code that limit performance. >>>> http://p.sf.net/sfu/intel-dev2devfeb >>>> _______________________________________________ >>>> Resteasy-developers mailing list >>>> Res...@li... >>>> https://lists.sourceforge.net/lists/listinfo/resteasy-developers >>>> >>>> >>> >> >> ------------------------------------------------------------------------------ >> Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses >> from deploying virtual desktops? How do next-generation virtual desktops >> provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ >> _______________________________________________ >> Resteasy-developers mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/resteasy-developers >> >> >> The information contained in this communication may be CONFIDENTIAL and is intended only for the use of the recipient(s) named above. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please notify the sender and delete/destroy the original message and any copy of it from your computer or paper files. >> ------------------------------------------------------------------------------ >> Doing More with Less: The Next Generation Virtual Desktop >> What are the key obstacles that have prevented many mid-market businesses >> from deploying virtual desktops? How do next-generation virtual desktops >> provide companies an easier-to-deploy, easier-to-manage and more affordable >> virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ >> _______________________________________________ >> Resteasy-developers mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/resteasy-developers >> > > ------------------------------------------------------------------------------ > Doing More with Less: The Next Generation Virtual Desktop > What are the key obstacles that have prevented many mid-market businesses > from deploying virtual desktops? How do next-generation virtual desktops > provide companies an easier-to-deploy, easier-to-manage and more affordable > virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > |