Sunday 15 January 2012

java - How to produce collections of links within the Links section using Spring HATEOAS -


I am trying to produce a JSON output similar to the example below:

  {"Link": {"self": {"href": "http://api.com/items"}, "item": [{href = "href": "http://api.com/items/ 1 "}, {" Href ":" http://api.com/items/2 "}]" data ": [{" item name ":" a "}, {" itemName ":" b "}]}  

Note that items is a collection of linked objects. How do I go about doing this with Spring Hats?

UPDATE: Adding the same relay in my UserResource gives me the following:

  "link": [{"rel": " Self "," href ":" http: // localhost: 8080 / sophia / user / administrator "}, {" rel ":" item "," href ":" http: // localhost: 8080 / sophia / companies / 01393048000170 / item / 1 "}, {" rel ":" item "," href ":" http: // localhost: 8080 / sophia / companies / 01393048000170 / items / 2 "}, {" rel ":" item " , "Href": "http: // localhost: 8080 / sophia / companies / 01393048000170 / items / 3"}]  

Many links with just a lot of relay Add.

  Resource Resources = New Resources (Data); Resource.add (new link ("...", "item")); Resource.add (new link ("...", "item"));  

No comments:

Post a Comment