title: Returning JSON as Response Spring Boot
body: <p>I am trying to get rest response as json instead I am getting as string.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>@RestController
  @RequestMapping("/api/")
  public class someController{
  
    @Autowired
    private SomeService someService;
  
    @GetMapping("/getsome")
    public Iterable&lt;SomeModel&gt; getData(){
      return someService.getData();
    }
  }
  </code></pre>
  
  <p><strong>Service</strong></p>
  
  <pre><code>@Autowired
  private SomeRepo someRepo;
  
  public Iterable&lt;someModel&gt; getData(){
    return someRepo.findAll();
  }
  </code></pre>
  
  <p><strong>Repository</strong></p>
  
  <pre><code>public interface SomeRepo extends CrudRepository&lt;SomeModel,Integer&gt;{
  
  }
  </code></pre>
  
  <p><strong>Models</strong></p>
  
  <pre><code>@Entity
  @Table(name="some_table")
  public class SomeModel{
  
    @Id
    @Column(name="p_col", nullable=false)
    private Integer id;
    @Column(name="s_col")
    private String name
    @Column(name="t_col")
    private String json;   // this column contains json data
  
    //constructors, getters and setters
  }
  </code></pre>
  
  <p>when I run <em>localhost:8080/api/getsome</em> I am getting:</p>
  
  <pre><code>[
   {
      "p_col":1,
      "s_col":"someName",
      "t_col":" 
  {\r\n\t"school_name\":\"someSchool\",\t\r\n\t"grade\":"A\",\r\n\t\"class\": 
   [{\"course\":"abc",\t"course_name\":\"def" }]}"
    }
  ]
  </code></pre>
  
  <p>Field <em>t_col</em> is returning string instead of json. How do I get json objects in response?</p>
  
  <p>As for the database, the three columns are int, varchar and varchar.</p>
  
  <p>Any help would be appreciated. Thanks !!</p>