title: Return Hashmap from Spring Rest API
body: <p>I want to use this code to get some data from Rest API:</p>
  <pre><code>public Map&lt;Integer, String&gt; getCategoriesList() {
  
          Map&lt;Integer, String&gt; list = new HashMap&lt;&gt;();
          list.put(1, &quot;Electronics&quot;);
          list.put(2, &quot;Outdoor and Sports&quot;);
          list.put(3, &quot;Home and Garden&quot;);
          list.put(4, &quot;Home appliances&quot;);
          list.put(5, &quot;Air conditioners and heaters&quot;);
          list.put(6, &quot;IT accessories&quot;);
          list.put(7, &quot;Photo and Video&quot;);
          list.put(8, &quot;TV Video and Gaming&quot;);
  
          return list;
      }
  
  @GetMapping(&quot;categories&quot;)
  public ResponseEntity&lt;List&lt;String&gt;&gt; getCategoriesList() {
  
      return (ResponseEntity&lt;List&lt;String&gt;&gt;) categoriesService.getCategoriesList();
  }
  </code></pre>
  <p>I get error: <code>class java.util.HashMap cannot be cast to class org.springframework.http.ResponseEntity</code></p>
  <p>What is the appropriate way to return this data as a response?</p>