title: Spring Boot JSON parse error: Cannot deserialize error
body: <pre><code>{
      &quot;timestamp&quot;: &quot;2018-07-18T11:02:29.789+0000&quot;,
      &quot;status&quot;: 400,
      &quot;error&quot;: &quot;Bad Request&quot;,
      &quot;message&quot;: &quot;JSON parse error: Cannot deserialize instance of `com.springboot.sprinboot.model.Users` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.springboot.sprinboot.model.Users` out of START_ARRAY token\n at [Source: (PushbackInputStream); line: 1, column: 1]&quot;,
      &quot;path&quot;: &quot;/rest/users/&quot;
  }
  </code></pre>
  <p>That's Error Message</p>
  <pre><code>package com.springboot.sprinboot.resource;
  
  import com.springboot.sprinboot.model.Users;
  import com.springboot.sprinboot.repository.UsersRepository;
  import org.apache.tomcat.util.http.parser.MediaType;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  import org.springframework.web.bind.annotation.RestController;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.GetMapping;
  
  import java.awt.*;
  import java.util.List;
  
  @RestController
  @RequestMapping(value = &quot;/rest/users&quot;)
  public class UsersResource {
  
      @Autowired
      UsersRepository usersRepository;
  
      @GetMapping(value = &quot;/all&quot;)
      public List&lt;Users&gt; getAll(){
          return usersRepository.findAll();
  
      }
  
      
       @PostMapping (value = &quot;/load&quot;)
  public List&lt;Users&gt; persist(@RequestBody final Users users){
      usersRepository.save(users);
      return usersRepository.findAll();
      }
  }
  
  UsersResource.java
  
  package com.springboot.sprinboot.repository;
  
  import com.springboot.sprinboot.model.Users;
  import org.springframework.data.jpa.repository.JpaRepository;
  
  public interface UsersRepository extends JpaRepository&lt;Users, Integer&gt; {
  }
  </code></pre>
  <p>UsersRepository.java</p>
  <pre><code>package com.springboot.sprinboot.model;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  
  @Entity
  public class Users {
  
      @Id
      @GeneratedValue
      @Column(name = &quot;id&quot;)
      private Integer id;
      @Column(name = &quot;name&quot;)
      private String name;
      @Column(name = &quot;team_name&quot;)
      private String teamName;
      @Column (name = &quot;salary&quot;)
      private Integer salary;
  
      public Users() {
      }
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getTeamName() {
          return teamName;
      }
  
      public void setTeamName(String teamName) {
          this.teamName = teamName;
      }
  
      public Integer getSalary() {
          return salary;
      }
  
      public void setSalary(Integer salary) {
          this.salary = salary;
      }
  }
  </code></pre>
  <p>Users.java</p>
  <p>Summary;</p>
  <p>At address (localhost:8080/rest/users/all), Get operation is running smoothly.
  But when I try to create a new User with post at (localhost:8080/rest/users/load), I get error:</p>
  <blockquote>
  <p>&quot;message&quot;: &quot;JSON parse error: Cannot deserialize instance of <code>com.springboot.sprinboot.model.Users</code> out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of <code>com.springboot.sprinboot.model.Users</code> out of START_ARRAY token\n at [Source: (PushbackInputStream); line: 1, column: 1]&quot;,</p>
  </blockquote>
  <p>example json</p>
  <pre><code>[
      {
          &quot;id&quot;: 2,
          &quot;name&quot;: &quot;omer&quot;,
          &quot;teamName&quot;: &quot;omr&quot;,
          &quot;salary&quot;: 200
      }
  ]
  </code></pre>
  <hr />
  <h1>Solved</h1>
  <pre><code>{      
          &quot;name&quot;: &quot;omer&quot;,
          &quot;teamName&quot;: &quot;omr&quot;,
          &quot;salary&quot;: 200
  }
  </code></pre>
  <p>everyone thank you, I was need can't add because id is primary key.</p>