Community
Participate
Working Groups
Add support for marshalling to JsonStructure (support both JsonObject and JsonArray). For this we should a JsonStructureResult that implements javax.xml.transform.Result. This new result will then be able to be used with the following unmarshal methods: Marshaller.marshal(Object, Result) The JsonStructureResult should be able to be created with or without a root JsonStructure (much like a DOMResult). When it is created without it should produce a new top-level JsonStructure, and when it is created with it should marshal into the existing JsonStructure.
Created attachment 232906 [details] Work in progress
Potentially add a method like the following to JsonObjectBuilderResult public JsonObjectBuilder marshal(Marshaller marshaller, Object object) throws JAXBException { marshaller.marshal(object, this); return jsonObjectBuilder; } This would let us fit into the JsonObjectBuilder APIs a little neater (compare how the 2nd and 4th phone numbers are added): JsonObjectBuilderResult result = new JsonObjectBuilderResult(cellPhoneBuilder); marshaller.marshal(phoneNumber, result); JsonObject jsonObject = Json.createObjectBuilder() .add("id", 123) .add("firstName", "Jane") .addNull("lastName") .add("phoneNumbers", Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "work") .add("number", "555-1111") ) .add(new JsonObjectBuilderResult().marshal(marshaller, phoneNumber)) .add(Json.createObjectBuilder() .add("type", "home") .add("number", "555-2222") ) .add(result.getJsonObjectBuilder()) ) .build();
Created attachment 233631 [details] Work in progress
Created attachment 233635 [details] Work in progress
Created attachment 233675 [details] Proposed changes
Created attachment 233682 [details] Additional patch
Created attachment 233709 [details] Additional patch
Created attachment 233732 [details] Additional update (rename)
Created attachment 233733 [details] Additional update (rename)
Example: - http://blog.bdoughan.com/2013/07/eclipselink-moxy-and-java-api-for-json.html
Changes checked in previously but bug wasn't closed.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink