Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/406697"
< EclipseLink | DesignDocs
(→Note/Issues) |
(→Design) |
||
Line 92: | Line 92: | ||
== Design == | == Design == | ||
A new mapping will be created XMLVariableXPathMapping and it will extend the AnyCollectionMapping | A new mapping will be created XMLVariableXPathMapping and it will extend the AnyCollectionMapping | ||
+ | |||
+ | This mapping will assume that the key names are unique so will never write ['s in JSON | ||
== Note/Issues == | == Note/Issues == |
Revision as of 15:35, 2 May 2013
Document History
- April 26, 2013 - Initial Draft
Requirements
- Related Enhancement Request - bug 406697
- Required for JSON schema generation - JSON Schema Generation
API
The following annotation will be added
org.eclipse.persistence.oxm.annotations.XmlVariableNode
@Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface XmlVariableNode { String attributeName(); }
Example
@XmlRootElement public class Root { public String name; @XmlVariableNode(attributeName="thingName") public List<Thing> things; } public class Thing { @XmlTransient public String thingName; public String thingValue; }
Root r = new Root(); r.name = "theRootName"; r.things = new ArrayList<Thing>(); Thing thing1 = new Thing(); thing1.thingName = "thinga"; thing1.thingValue = "thingavalue"; Thing thing2 = new Thing(); thing2.thingName = "thingb"; thing2.thingValue = "thingbvalue"; Thing thing3 = new Thing(); thing3.thingName = "thingc"; thing3.thingValue = "thingcvalue"; r.things.add(thing1); r.things.add(thing2); r.things.add(thing3);
marshaller.marshal(r, System.out) XML <root> <name>theRootName</name> <thinga> <thingValue>thingavalue</thingValue> </thinga> <thingb> <thingValue>thingbvalue</thingValue> </thingb> <thingc> <thingValue>thingcvalue</thingValue> </thingc> </root>
marshaller.marshal(r, System.out) JSON {"root":{ "name":"theRootName" "thinga":{ "thingValue":"thingavalue"}, "thingb":{ "thingValue":"thingbvalue"}, "thingc":{ "thingValue":"thingcvalue"} }}
Design
A new mapping will be created XMLVariableXPathMapping and it will extend the AnyCollectionMapping
This mapping will assume that the key names are unique so will never write ['s in JSON
Note/Issues
- inheritance
- List<Object>
- single case ie:not on a collection XMLVariableXPathObjectMapping XMLVariableXPathCollectionMapping
- external bindings
- don`t write out that property itself as nested if it is the variable field - currently need to mark that property as transient.
- startcollection and endcollection [ ]'s in JSON
- add type/class to the annotation