title: How fix this JSON parse error in Spring Boot?
body: <p>I have created a Restfull service with Spring, just a simple sing-up API to sing-up an admin user:</p>
  
  <pre><code>@PostMapping("/admin/signup")
      public ResponseEntity&lt;?&gt; signupAdmin(@RequestBody Admin admin){
          if(adminRepository.existsById(admin.getUsername())){
              return new ResponseEntity&lt;String&gt;("Username already taken", HttpStatus.FOUND);
          }else{
              adminRepository.save((Admin) admin);
              return new ResponseEntity&lt;Admin&gt;( adminRepository.findByUsername(admin.getUsername()), HttpStatus.OK);
          }
  }
  </code></pre>
  
  <p>Here the code, with missed Getters and Setters:</p>
  
  <pre><code>@MappedSuperclass
  public class User {
      @Id
      protected String username;
      protected String email;
      protected String password;
  }
  
  @Entity
  public class Admin extends User{
  
      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
      private Set&lt;Survey&gt; created_survey;
  }
  
  @Entity
  public class Customer extends User{
  
      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
      private List&lt;Choice&gt; choices;
  }
  </code></pre>
  
  <p>I have tried a lot, but i can't fix that, here is the json to be parsed with Admin</p>
  
  <pre><code>{username: "aaa", email: "aaa@", password: "aaa", created_survey: []}
  </code></pre>
  
  <p>And this is this is the error:</p>
  
  <pre><code>POST "/admin/signup", parameters={}
  
  Mapped to public org.springframework.http.ResponseEntity&lt;com.modal.Admin&gt; com.controller.LoginController.signupAdmin(com.modal.Admin)
  
  Could not resolve parameter [0] in public org.springframework.http.ResponseEntity&lt;com.modal.Admin&gt; com.controller.LoginController.signupAdmin(com.modal.Admin): JSON parse error:Cannot deserialize instance of `com.modal.Admin` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.modal.Admin` out of START_ARRAY token
   at [Source: (PushbackInputStream); line: 1, column: 1]
  
  Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `com.modal.Admin` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.modal.Admin` out of START_ARRAY token
   at [Source: (PushbackInputStream); line: 1, column: 1]]
  
  Completed 400 BAD_REQUEST
  </code></pre>
  
  <p>Maybe subclasses don't inherit fields.
  I know it's hard to find a way to solve this error, i hope someone can just help me</p>
  
  <h2>SOLVED</h2>
  
  <pre><code>let user = {"username": "user", "email":"email", "password":"password"};
  http = new XMLHttpRequest();
  ...
  http.send(user); //WRONG
  </code></pre>
  
  <p>How i solved it</p>
  
  <pre><code>let user = {"username": "user", "email":"email", "password":"password"};
  http = new XMLHttpRequest();
  ...
  http.send(JSON.stringify(user)); //CORRECT
  </code></pre>
  
  <p>I don't know why JSON.stringify is necessary, but it works</p>