0

I am using spring data rest web mvc 2.2.1.RELEASE. I am expecting out in below format

{
    "content": [ {
        "price": 499.00,
        "description": "Apple tablet device",
        "name": "iPad",
        "links": [ {
            "rel": "self",
            "href": "http://localhost:8080/product/1"
        } ],
        "attributes": {
            "connector": "socket"
        }
    }, {
        "price": 49.00,
        "description": "Dock for iPhone/iPad",
        "name": "Dock",
        "links": [ {
            "rel": "self",
            "href": "http://localhost:8080/product/3"
        } ],
        "attributes": {
            "connector": "plug"
        }
    } ],
    "links": [ {
        "rel": "product.search",
        "href": "http://localhost:8080/product/search"
    } ]
}   

But I am getting output like this :

    {
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/people{?page,size,sort}",
      "templated" : true
    },
    "search" : {
      "href" : "http://localhost:8080/people/search"
    }
  },
  "_embedded" : {
    "people" : [ {
      "firstName" : "Frodo",
      "lastName" : "Baggins",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/people/1"
        }
      }
    }, {
      "firstName" : "Frodo",
      "lastName" : "shukla",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/people/2"
        }
      }
    } ]
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
    }

Why I am getting _embedded in place of content _links in place of links

and rel attribute is missing..

I am try to de-serializing json out back to hateos Resource but because of change in format I am not able to achieve this .

Thanks for help in advance

S Shukla
  • 77
  • 7

3 Answers3

0

SDR 2.X outputs content in HAL format and hence the _links & _embedded. Refer to HAL specification for further details

Stackee007
  • 3,196
  • 1
  • 26
  • 39
0

The result you are expecting is the one produced by spring-data-rest 1.x. The default format in 2.x is HAL. But a fall back to the old format should possible by changing the default media format as stated in the resolution of this bug: https://jira.spring.io/browse/DATAREST-213.

user1387786
  • 302
  • 3
  • 14
0

I adapted my JPA Rest Client as per HAL specification/

S Shukla
  • 77
  • 7