This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 411377 - JSON-P - Marshal to javax.json.JsonObjectBuilder/JsonArrayBuilder
Summary: JSON-P - Marshal to javax.json.JsonObjectBuilder/JsonArrayBuilder
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Denise Smith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 405161
  Show dependency tree
 
Reported: 2013-06-21 10:23 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:09 EDT (History)
1 user (show)

See Also:


Attachments
Work in progress (42.80 KB, patch)
2013-06-28 16:07 EDT, Denise Smith CLA
no flags Details | Diff
Work in progress (85.85 KB, patch)
2013-07-19 15:43 EDT, Denise Smith CLA
no flags Details | Diff
Work in progress (79.01 KB, patch)
2013-07-19 16:16 EDT, Denise Smith CLA
no flags Details | Diff
Proposed changes (80.15 KB, patch)
2013-07-22 11:02 EDT, Denise Smith CLA
no flags Details | Diff
Additional patch (7.69 KB, patch)
2013-07-22 16:55 EDT, Denise Smith CLA
no flags Details | Diff
Additional patch (7.45 KB, patch)
2013-07-23 10:09 EDT, Denise Smith CLA
no flags Details | Diff
Additional update (rename) (72.58 KB, patch)
2013-07-23 16:40 EDT, Denise Smith CLA
no flags Details | Diff
Additional update (rename) (72.40 KB, patch)
2013-07-23 16:51 EDT, Denise Smith CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2013-06-21 10:23:25 EDT
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.
Comment 1 Denise Smith CLA 2013-06-28 16:07:22 EDT
Created attachment 232906 [details]
Work in progress
Comment 2 Blaise Doughan CLA 2013-06-28 16:38:07 EDT
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();
Comment 3 Denise Smith CLA 2013-07-19 15:43:11 EDT
Created attachment 233631 [details]
Work in progress
Comment 4 Denise Smith CLA 2013-07-19 16:16:51 EDT
Created attachment 233635 [details]
Work in progress
Comment 5 Denise Smith CLA 2013-07-22 11:02:15 EDT
Created attachment 233675 [details]
Proposed changes
Comment 6 Denise Smith CLA 2013-07-22 16:55:26 EDT
Created attachment 233682 [details]
Additional patch
Comment 7 Denise Smith CLA 2013-07-23 10:09:30 EDT
Created attachment 233709 [details]
Additional patch
Comment 8 Denise Smith CLA 2013-07-23 16:40:26 EDT
Created attachment 233732 [details]
Additional update (rename)
Comment 9 Denise Smith CLA 2013-07-23 16:51:17 EDT
Created attachment 233733 [details]
Additional update (rename)
Comment 11 Denise Smith CLA 2014-05-23 15:59:50 EDT
Changes checked in previously but bug wasn't closed.
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:09:56 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink