title: Spring HATEOAS links return in HAL format for single objects, and the spec format for an array of objects
body: <p>I am using Spring HATEOAS 0.20 (also tried 0.23) and there seems to be very strange behavior when returning a single object vs. an array of objects.  When returning a single object, the resulting JSON returns HATEOAS links that are formatted via the HAL spec ("_links", which I do not want):</p>
  
  <pre><code>{
    "_Id": 161,
    ...
    "_links": {
      "self": {
        "href": "http://localhost:8080/library/161"
      }
    }
  }
  </code></pre>
  
  <p>When returning an array of objects, the resulting JSON returns HATEOAS links in the spec format ("links", which I do want):</p>
  
  <pre><code>[
    {
      "_Id": 277,
      ...
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:8080/library/277"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>I have not specified @EnableHypermediaSupport, so HAL should not be supported.  But, yet I still get HAL format when returning a single object.</p>
  
  <p>Does anyone know why this would be happening?
  What need to be done to return a single object with HATEOAS links via the HATEOAS spec?</p>
  
  <p><strong>===== UPDATE TO POST BASED ON REQUEST FOR MORE INFO =====</strong></p>
  
  <p>If I return the JSON load using the following code, I get the HAL links:</p>
  
  <pre><code>//
  //------------------- Get Single Membership As Single Object ----------------------------------------------
  //
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @RequestMapping(value = REQUEST_GET_MEMBERSHIP, method = RequestMethod.GET,  produces = { MediaType.APPLICATION_JSON_VALUE })
  public ResponseEntity&lt;MembershipResource&gt; getMembership(@PathVariable("membership-id") Integer membershipId) {
      Membership membership = membershipRepository.findOne(membershipId);
  
      if (membership == null) {
          HttpHeaders headers = new HttpHeaders();
          headers.add("error", "Membership with ID of " + membershipId + " does not exist.");
          return new ResponseEntity&lt;MembershipResource&gt;(headers, HttpStatus.NOT_FOUND);
      }
  
      MembershipResourceAssembler assm = new MembershipResourceAssembler();
      MembershipResource membershipResource = assm.toResource(membership);
  
      System.out.println("membership id: " + membership.getId());
      return new ResponseEntity&lt;MembershipResource&gt;(membershipResource, HttpStatus.OK);
  }
  </code></pre>
  
  <p>The above will produce HAL-specification style links:</p>
  
  <pre><code>{
    "_Id": 277,
    "member": {
      "_Id": 112,
      "title": "Mr.",
      "firstName": "ABC",
      "middleName": "",
      "lastName": "XYZ",
      "active": true,
      "_links": {
        "self": {
          "href": "http://localhost:8080/members/112"
        }
      }
    },
    "membershipTermType": "2016",
    "card": {
      "_Id": 27,
      "name": "27",
      "graphicUrl": "",
      "number": 27,
    },
    "active": false,
    "paid": true,
    "renewal": true,
    "termsAndConditionsAcknowledged": true,
    "_links": {
      "self": {
        "href": "http://localhost:8080/memberships/277"
      }
    }
  }
  </code></pre>
  
  <p>If I modify the method to return a List of the single member, the returned JSON load is with HATEOAS-specification links:</p>
  
  <pre><code>//
  //------------------- Get Single Membership As List --------------------------------------------------------
  //
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @RequestMapping(value = REQUEST_GET_MEMBERSHIP, method = RequestMethod.GET,  produces = { MediaType.APPLICATION_JSON_VALUE })
  public ResponseEntity&lt;List&lt;MembershipResource&gt;&gt; getMembership(@PathVariable("membership-id") Integer membershipId) {
      Membership membership = membershipRepository.findOne(membershipId);
  
      if (membership == null) {
          HttpHeaders headers = new HttpHeaders();
          headers.add("error", "Membership with ID of " + membershipId + " does not exist.");
          return new ResponseEntity&lt;List&lt;MembershipResource&gt;&gt;(headers, HttpStatus.NOT_FOUND);
      }
  
      MembershipResourceAssembler assm = new MembershipResourceAssembler();
          MembershipResource membershipResource = assm.toResource(membership);
  
      ArrayList&lt;MembershipResource&gt; list = new ArrayList&lt;MembershipResource&gt;();
      list.add(membershipResource);
  
      System.out.println("membership id: " + membership.getId());
      return new ResponseEntity&lt;List&lt;MembershipResource&gt;&gt;(list, HttpStatus.OK);
  }
  </code></pre>
  
  <p>The above will produce HATEOAS-specification style links:</p>
  
  <pre><code>[
    {
      "_Id": 277,
      "member": {
        "_Id": 112,
        "title": "Mr.",
        "firstName": "ABC",
        "middleName": "",
        "lastName": "XYZ",
        "active": true,
        "links": [
          {
            "rel": "self",
            "href": "http://localhost:8080/members/112"
          }
        ]
      },
      "membershipTermType": "2016",
      "card": {
        "_Id": 27,
        "name": "27",
        "graphicUrl": "",
        "number": 27,
        "links": []
      },
      "active": false,
      "renewal": true,
      "paid": true,
      "termsAndConditionsAcknowledged": true,
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:8080/memberships/277"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>Does anyone know why this would be happening?
  What need to be done to return a single object with HATEOAS links via the HATEOAS spec?</p>