title: Some clarification on Hateoas + SpringBoot + Kotlin (structuring responses)
body: <p>So as I understand there are kind of two (or at least two) formats out there that Spring Hateoas supports : <code>collection+json</code> &amp; <code>hal</code></p>
  
  <p>I'm trying to use the <code>HAL</code> format (I think) but I'm having trouble getting one of my elements to render correctly</p>
  
  <h3>Function 1: (Returns Single <code>Resource</code>)</h3>
  
  <pre><code>@GetMapping("/test2/{array_index}")
  fun test2(@PathVariable array_index: Int): ResponseEntity&lt;Resource&lt;SDDFService&gt;&gt; {
  
      val service = SDDFService(globals.advertisements[array_index])
  
      return ResponseEntity(Resource(service), HttpStatus.OK)
  }
  </code></pre>
  
  <p>The <code>JSON</code> returned by this call is:</p>
  
  <pre><code>{
    "content": {
      "serviceID": "FMS",
      "peerID": "FlightSim_0977",
      "peerName": "FlightSim",
      "translator": "SDDFTranslator:AdvTranslator",
      "transporter": "SDDFTransporter:CMSVTransporter#trumpet.mitre.org@41375",
      "contentIterator": [
        {
          "comment": "",
          "units": "",
          "type": "STRING",
          "key": "fms",
          "nestedContentSet": null
        }
      ]
    },
    "_links": {
      "peer_id": {
        "href": "http://localhost:8090/test/peer_id/FlightSim_0977"
      },
      "peer_name": {
        "href": "http://localhost:8090/test/peer_name/FlightSim"
      },
      "service_name": {
        "href": "http://localhost:8090/test/service/FMS"
      }
    }
  }
  </code></pre>
  
  <p>I like this because our root is <code>content</code> and we have the HAL style <code>_links</code></p>
  
  <h3>Version 2 - Multiple returns</h3>
  
  <p>My issue is when I start returning a collection things get a little funky:</p>
  
  <pre><code>@GetMapping("/test3/{array_index}")
  fun test3(@PathVariable array_index: Int): ResponseEntity&lt;Resources&lt;SDDFService&gt;&gt; {
  
      val service1 = SDDFService(globals.advertisements[array_index])
      val service2 = SDDFService(globals.advertisements[array_index+1])
  
      return ResponseEntity(
              Resources(listOf(service1, service2)),
              HttpStatus.OK
      )
  }
  </code></pre>
  
  <p>```</p>
  
  <p>The return I get looks like:</p>
  
  <pre><code>{
    "_embedded": {
      "sDDFServiceList": [
        {
          "content": {
            "serviceID": "FMS",
            "peerID": "FlightSim_0977",
            "peerName": "FlightSim",
            "translator": "SDDFTranslator:AdvTranslator",
            "transporter": "SDDFTransporter:CMSVTransporter#trumpet.mitre.org@41375",
            "contentIterator": [
  .etc
  </code></pre>
  
  <p>My question is - is there a way to change the name of <code>sDDFServiceList</code>.  I've tried a variety of annotations and nothing seems to change it (except changing the class name itself)</p>
  
  <h3>Class Def</h3>
  
  <pre><code>@JsonRootName("ROOT")
  @JsonTypeName("typeName")
  data class SDDFService @JsonCreator
  constructor(@JsonProperty("content")  val advertisement: SDDFAdvertisement) : ResourceSupport() {
  
  init {
      add(linkTo(methodOn(TestController::class.java).peerID(advertisement.peerID.toString())).withRel("peer_id"))
      add(linkTo(methodOn(TestController::class.java).peerName(advertisement.peerName.toString())).withRel("peer_name"))
      add(linkTo(methodOn(TestController::class.java).getByServiceName(advertisement.serviceID)).withRel("service_name"))
  }
  }
  </code></pre>
  
  <p>I've gone through just about every stack post I can find and tried a ton of different things - but as it stands all I can come up with is changing my class name - which will still get the <code>List</code> appended onto the end of it.</p>
  
  <p>Why I don't understand is why a single <code>Resource</code> gets a <code>content</code> field but a <code>resources</code> object seems to get both <code>_embedded</code> and <code>&lt;className&gt;List</code> fields</p>