title: Can not deserialize instance Jackson And JSON
body: <p>I Keep getting this error each time I tried to save a credentials entity object.</p>
  
  <blockquote>
    <p>[WARN] org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of com.portal.app.domain.Credentials out of START_ARRAY token
     at [Source: java.io.PushbackInputStream@246feef4; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.wiportal.app.domain.Credentials out of START_ARRAY token
     at [Source: java.io.PushbackInputStream@246feef4; line: 1, column: 1]</p>
  </blockquote>
  
  <p>This is the code for my Credentials Domain Class:</p>
  
  <pre><code>package com.portal.app.domain;
  
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  import org.springframework.data.elasticsearch.annotations.Document;
  
  import javax.validation.constraints.NotNull;
  import javax.persistence.*;
  import javax.validation.constraints.*;
  import java.io.Serializable;
  import java.util.HashSet;
  import java.util.Set;
  import java.util.Objects;
  
  /**
  * A Credentials.
  */
  @Entity
  @Table(name = "credentials")
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  @Document(indexName = "credentials")
  public class Credentials implements Serializable {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  @NotNull
  @Column(name = "password", nullable = false)
  private String password;
  
  @NotNull
  @Column(name = "secret_question1", nullable = false)
  private String secretQuestion1;
  
  @NotNull
  @Column(name = "secret_question2", nullable = false)
  private String secretQuestion2;
  
  @NotNull
  @Column(name = "secret_answer1", nullable = false)
  private String secretAnswer1;
  
  @NotNull
  @Column(name = "secret_answer2", nullable = false)
  private String secretAnswer2;
  
  @JsonIgnore
  @OneToOne(mappedBy = "credentials", cascade=CascadeType.ALL)
  private User user;
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public String getSecretQuestion1() {
      return secretQuestion1;
  }
  
  public void setSecretQuestion1(String secretQuestion1) {
      this.secretQuestion1 = secretQuestion1;
  }
  
  public String getSecretQuestion2() {
      return secretQuestion2;
  }
  
  public void setSecretQuestion2(String secretQuestion2) {
      this.secretQuestion2 = secretQuestion2;
  }
  
  public String getSecretAnswer1() {
      return secretAnswer1;
  }
  
  public void setSecretAnswer1(String secretAnswer1) {
      this.secretAnswer1 = secretAnswer1;
  }
  
  public String getSecretAnswer2() {
      return secretAnswer2;
  }
  
  public void setSecretAnswer2(String secretAnswer2) {
      this.secretAnswer2 = secretAnswer2;
  }
  
  public User getUser() {
      return user;
  }
  
  public void setUser(User user) {
      this.user = user;
  }
  
  @Override
  public boolean equals(Object o) {
      if (this == o) {
          return true;
      }
      if (o == null || getClass() != o.getClass()) {
          return false;
      }
      Credentials credentials = (Credentials) o;
      return Objects.equals(id, credentials.id);
  }
  
  @Override
  public int hashCode() {
      return Objects.hashCode(id);
  }
  
  @Override
  public String toString() {
      return "Credentials{" +
          "id=" + id +
          ", password='" + password + "'" +
          ", secretQuestion1='" + secretQuestion1 + "'" +
          ", secretQuestion2='" + secretQuestion2 + "'" +
          ", secretAnswer1='" + secretAnswer1 + "'" +
          ", secretAnswer2='" + secretAnswer2 + "'" +
          '}';
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And This is the code for my rest resource:</p>
  
  <pre><code>package com.portal.app.web.rest;
  
  import com.codahale.metrics.annotation.Timed;
  import com.portal.app.domain.Credentials;
  import com.portal.app.repository.CredentialsRepository;
  import com.portal.app.repository.search.CredentialsSearchRepository;
  import com.portal.app.web.rest.util.HeaderUtil;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.http.HttpHeaders;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.MediaType;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  import javax.inject.Inject;
  import javax.validation.Valid;
  import java.net.URI;
  import java.net.URISyntaxException;
  import java.util.List;
  import java.util.Optional;
  import java.util.stream.Collectors;
  import java.util.stream.StreamSupport;
  
  import static org.elasticsearch.index.query.QueryBuilders.*;
  
  /**
  * REST controller for managing Credentials.
  */
  @RestController
  @RequestMapping("/api")
  public class CredentialsResource {
  
  private final Logger log =         LoggerFactory.getLogger(CredentialsResource.class);
  
  @Inject
  private CredentialsRepository credentialsRepository;
  
  @Inject
  private CredentialsSearchRepository credentialsSearchRepository;
  
  /**
   * POST  /credentialss -&gt; Create a new credentials.
   */
  @RequestMapping(value = "/credentialss",
      method = RequestMethod.POST,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity&lt;Credentials&gt; createCredentials(@Valid @RequestBody Credentials credentials) throws URISyntaxException {
      log.debug("REST request to save Credentials : {}", credentials);
      if (credentials.getId() != null) {
          return ResponseEntity.badRequest().header("Failure", "A new credentials cannot already have an ID").body(null);
      }
      Credentials result = credentialsRepository.save(credentials);
      credentialsSearchRepository.save(result);
      return ResponseEntity.created(new URI("/api/credentialss/" + result.getId()))
          .headers(HeaderUtil.createEntityCreationAlert("credentials", result.getId().toString()))
          .body(result);
  }
  
  /**
   * PUT  /credentialss -&gt; Updates an existing credentials.
   */
  @RequestMapping(value = "/credentialss",
      method = RequestMethod.PUT,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity&lt;Credentials&gt; updateCredentials(@Valid @RequestBody Credentials credentials) throws URISyntaxException {
      log.debug("REST request to update Credentials : {}", credentials);
      if (credentials.getId() == null) {
          return createCredentials(credentials);
      }
      Credentials result = credentialsRepository.save(credentials);
      credentialsSearchRepository.save(credentials);
      return ResponseEntity.ok()
          .headers(HeaderUtil.createEntityUpdateAlert("credentials", credentials.getId().toString()))
          .body(result);
  }
  
  /**
   * GET  /credentialss -&gt; get all the credentialss.
   */
  @RequestMapping(value = "/credentialss",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public List&lt;Credentials&gt; getAllCredentialss(@RequestParam(required = false) String filter) {
      if ("user-is-null".equals(filter)) {
          log.debug("REST request to get all Credentialss where user is null");
          return StreamSupport
              .stream(credentialsRepository.findAll().spliterator(), false)
              .filter(credentials -&gt; credentials.getUser() == null)
              .collect(Collectors.toList());
      }
  
      log.debug("REST request to get all Credentialss");
      return credentialsRepository.findAll();
  }
  
  /**
   * GET  /credentialss/:id -&gt; get the "id" credentials.
   */
  @RequestMapping(value = "/credentialss/{id}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity&lt;Credentials&gt; getCredentials(@PathVariable Long id) {
      log.debug("REST request to get Credentials : {}", id);
      return Optional.ofNullable(credentialsRepository.findOne(id))
          .map(credentials -&gt; new ResponseEntity&lt;&gt;(
              credentials,
              HttpStatus.OK))
          .orElse(new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND));
  }
  
  /**
   * DELETE  /credentialss/:id -&gt; delete the "id" credentials.
   */
  @RequestMapping(value = "/credentialss/{id}",
      method = RequestMethod.DELETE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity&lt;Void&gt; deleteCredentials(@PathVariable Long id) {
      log.debug("REST request to delete Credentials : {}", id);
      credentialsRepository.delete(id);
      credentialsSearchRepository.delete(id);
      return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert("credentials", id.toString())).build();
  }
  
  /**
   * SEARCH  /_search/credentialss/:query -&gt; search for the credentials corresponding
   * to the query.
   */
  @RequestMapping(value = "/_search/credentialss/{query}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public List&lt;Credentials&gt; searchCredentialss(@PathVariable String query) {
      return StreamSupport
          .stream(credentialsSearchRepository.search(queryStringQuery(query)).spliterator(), false)
          .collect(Collectors.toList());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am creating a java-script object on the front end matching all the attributes of credentials, but I keep getting the error each time I am trying to save it.</p>