On Tuesday, 1 April 2014, Gary Gregory <[email protected]> wrote:
> Also interesting: Google GSON in on my Eclipse project CP, so it must be > brought in... somehow... > > Could be mongo or couch? > Gary > > > On Tue, Apr 1, 2014 at 5:37 PM, Gary Gregory <[email protected]>wrote: > > JacksonXmlProperty? Why not JsonProperty? Couldn't you then use JSON or > XML? Still learning Jackson... > > Gary > > > On Tue, Apr 1, 2014 at 4:49 PM, Ralph Goers <[email protected]>wrote: > > I just did this the other day for both XML and JSON. > > For XML I did: > > public static TransactionRequest deserialize(String xmlFile) { > try { > XmlMapper mapper = new XmlMapper(); > InputStream stream = new FileInputStream(xmlFile); > return mapper.readValue(stream, TransactionRequest.class); > } catch (Exception ex) { > ex.printStackTrace(); > } > return null; > } > public static TransactionRequest deserialize(String xmlFile) { > try { > XmlMapper mapper = new XmlMapper(); > InputStream stream = new FileInputStream(xmlFile); > return mapper.readValue(stream, TransactionRequest.class); > } catch (Exception ex) { > ex.printStackTrace(); > } > return null; > } > > Where needed I used things like: > > @JacksonXmlProperty(localName = "return") > private PostSale creditCardReturn; > > and > > @JacksonXmlProperty(isAttribute = true) > > For JSON I did > > public static JSONRequest deserialize(String json) > { > try > { > ObjectMapper mapper = new ObjectMapper(); > return mapper.readValue(json, JSONRequest.class); > } > catch (Exception ex) > { > ex.printStackTrace(); > } > return null; > } > > and > > public String serialize() > { > try > { > final ObjectMapper mapper = new ObjectMapper(); > return mapper.writeValueAsString(this); > } > catch (Exception ex) > { > ex.printStackTrace(); > } > return null; > } > > HTH, > > Ralph > > > On Apr 1, 2014, at 1:05 PM, Gary Gregory <[email protected]> wrote: > > Well... so much for Jackson making my life easy. Jackson says it > "supports" JAXB annotations but that must be only for the simplest cases. > Jackson does not work with the JAXB annotations I used on Log4jLogEvents. > This suppose this is not surprising. Back to the drawing board... > > Gary > > > On Tue, Apr 1, 2014 at 12:05 PM, Gary Gregory <[email protected]>wrote: > > All good ideas, thank you. The JSON API I know best is GSON, which let's > you listen to objects opening and closing. Maybe Jackson has something like > that... I'll have to dig in. > > Gary > > > On Tue, Apr 1, 2014 at 11:14 AM, Ralph Goers > <[email protected]>wrote: > > So you are hacking > > -- Matt Sicker <[email protected]>
