In one way JSON is better: arrays are expressed with their own markers [ and ]. While in XML, there is no such thing as an array. Sure, XML Schema defines min and max occurrences of elements, but you cannot tell from the XML syntax, a tag is a tag is a tag.
But I'm not sure where we are going with this thread now... yes, JAXB with JSON on top would be sweet, I'd other one. In the meantime, I've stubbed my toe on Jackson again, please see http://jackson-users.ning.com/forum/topics/how-do-i-override-the-jackson-stacktraceelement-deserializer-with Perhaps someone here knows enough about Jackson to reply. Cheers, Gary On Wed, Apr 2, 2014 at 11:35 AM, Matt Sicker <[email protected]> wrote: > No I know that it's not supported. I'm talking about in theory. All the > annotations available in JAXB: could a compatible JSON file be produced > using them? Or is XML (or JAXB) more expressive than JSON allows? The only > issue I can think of right away is that in JSON there's no difference > between an attribute and a nested element that contains a text node. I'll > look at what's available to see how feasible this idea is. If it works as > expected, I don't see why this couldn't evolve into a JSR for simpler use > of JSON wherever XML is used (at least via JAXB APIs). > > > On 2 April 2014 08:37, Gary Gregory <[email protected]> wrote: > >> It's possible for simple cases. It does not work for the annotating I >> did. Jackson does not support all JAXB annotations. >> >> Gary >> >> >> -------- Original message -------- >> From: Matt Sicker >> Date:04/02/2014 09:01 (GMT-05:00) >> To: Log4J Developers List >> Subject: Re: core.impl.Log4jLogEvent.LogEventProxy >> >> I meant if it is possible to reuse the JAXB annotations to (de)serialize >> JSON >> >> On Tuesday, 1 April 2014, Gary Gregory <[email protected]> wrote: >> >>> On Tue, Apr 1, 2014 at 4:40 PM, Matt Sicker <[email protected]> wrote: >>> >>>> With the existing JAXB annotations, do you think a compatible JSON file >>>> could be generated? >>>> >>> >>> No. Because it is not enough to annotate, you need custom un/marshallers. >>> >>> >>>> Minus namespaces of course (or even with namespaces by prepending them >>>> to keys). I might tinker with that later to see. Could get a structured >>>> text sort of API going out of it. >>>> >>> >>> This is what I have working now locally: >>> - XML unmarshalling (or "deserializing" in Jackson parlance) with JAXB. >>> - Unit tests for UDP and TCP passing >>> - Reworked the frameworf to neatly account for Serialization, XML and >>> JSON. >>> >>> My next step is to make the same changes I did with JAXB but with JSON. >>> >>> Then I'll have JSON unmarshalling working. >>> >>> Then I can see if I can unmarshal from XML using JSON. If that works, I >>> can remove the JAXB annotations. >>> >>> Next would be to replace all the custom code in the XML and JSON layouts >>> with Jackson (almost) one liners. >>> >>> Gary >>> >>> >>> >>> On 1 April 2014 11:03, Gary Gregory <[email protected]> wrote: >>> >>> On Tue, Apr 1, 2014 at 11:04 AM, Matt Sicker <[email protected]> wrote: >>> >>> Oh good catch. Maybe in JDK9 they'll put JSON in there. >>> >>> >>> One can only hope... but I do marvel at the lack of vision though, how >>> can this not be a tweak on top of JAXB? >>> >>> Gary >>> >>> >>> >>> >>> On 1 April 2014 07:39, Gary Gregory <[email protected]> wrote: >>> >>> OK, I've looked at EJ item #78, JAXB and Jackson a little more. >>> Initially, it looks like #78 is specific to Java Serializable objects but >>> the pattern should also apply to other "extralinguistic mechanisms" for >>> marshalling. I'll go back and see my JAXB implementation can be made >>> cleaner... >>> >>> Gary >>> >>> >>> On Mon, Mar 31, 2014 at 9:11 PM, Ralph Goers <[email protected]> wrote: >>> >>> I would use Jackson for JSON since we already use it. I don't recall >>> that we use an XML serializer anywhere else so I would stick with either >>> JAXB or Jackson since they don't introduce any new dependencies. >>> >>> Ralph >>> >>> On Mar 31, 2014, at 5:34 PM, Gary Gregory <[email protected]> >>> wrote: >>> >>> On Mon, Mar 31, 2014 at 10:21 AM, Ralph Goers < >>> [email protected]> wrote: >>> >>> Jackson will do both the JSON and XML if you want. If you can manage to >>> use the Proxy I think that would be better. >>> >>> Ralph >>> >>> So the options are: >>> >>> - JRE JAXB can do XML but not JSON >>> - Eclipse JAXB ("MOXy") can do XML and JSON >>> - Jackson can do both XML and JSON >>> >>> Because we already depend on Jackson it sounds like I should use that >>> instead of JAXB. >>> >>> Thoughts? >>> >>> Gary >>> >>> On Mar 31, 2014, at 7:04 AM, Gary Gregory <[email protected]> >>> wrote: >>> >>> On Mon, Mar 31, 2014 at 2:36 AM, Ralph Goers <[email protected] >>> > wrote: >>> >>> Out of curiosity, why does implementing an XML socket server require >>> touching the LogEvent? What are XMLLogEventI >>> >>> >>> >>> >>> -- >>> E-Mail: [email protected] | [email protected] >>> Java Persistence with Hibernate, Second >>> Edition<http://www.manning.com/bauer3/> >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >>> Spring Batch in Action <http://www.manning.com/templier/> >>> Blog: http://garygregory.wordpress.com >>> Home: http://garygregory.com/ >>> Tweet! http://twitter.com/GaryGregory >>> >> >> >> -- >> Matt Sicker <[email protected]> >> > > > > -- > Matt Sicker <[email protected]> > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
