title: JSON formatting with the extra nameValuePair inside retrofit request
body: <p>I am Sending one request to the server with the help of retrofit. Inside the body of request I have to pass JSON. From the POJO what I am getting in the form of JSON is below</p>
  
  <pre><code>    { 
          "id": "22",
          "firstname": "abcd",
          "lastname": "pqrl",
          "mail": "abcd@gmail.com",
          "access": true,
          "has_access": true,
          "iduser": 17,
          "accepted": false
      } 
  </code></pre>
  
  <p>instead of this what I have to send to the body is below </p>
  
  <pre><code>{
      "user": {
          "id": "22",
          "firstname": "abcd",
          "lastname": "pqrl",
          "mail": "abcd@gmail.com",
          "access": true,
          "has_access": true,
          "iduser": 17,
          "accepted": false
      }
  }
  </code></pre>
  
  <p>So what I have done is I have created JSONObject </p>
  
  <pre><code>final JSONObject parent = new JSONObject();
  
          try {
              parent.put("user",**myPojoJson**);
          } catch (JSONException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>With this I am able to get the JSON format I want but there is some extra value added to the JSON which is nameValuePair</p>
  
  <pre><code>{
    "nameValuePairs": {
      "User":  { 
          "id": "22",
          "firstname": "abcd",
          "lastname": "pqrl",
          "mail": "abcd@gmail.com",
          "access": true,
          "has_access": true,
          "iduser": 17,
          "accepted": false
      }
    }
  }
  </code></pre>
  
  <p><strong>I checked online there are solution to use Use com.google.gson.JsonObject instead of org.json.JSONObject. But Is there any way I can still use JSONObject and able to achieve what I want ?</strong></p>
  
  <p>EDIT with adding POJO</p>
  
  <pre><code>import com.google.gson.annotations.Expose;
  import com.google.gson.annotations.SerializedName;
  
  public class Vishvendu {
  
  @SerializedName("id")
  @Expose
  private String id;
  @SerializedName("firstname")
  @Expose
  private String firstname;
  @SerializedName("lastname")
  @Expose
  private String lastname;
  @SerializedName("mail")
  @Expose
  private String mail;
  @SerializedName("access")
  @Expose
  private Boolean access;
  @SerializedName("has_access")
  @Expose
  private Boolean hasAccess;
  @SerializedName("iduser")
  @Expose
  private Integer iduser;
  @SerializedName("accepted")
  @Expose
  private Boolean accepted;
  
  public String getId() {
  return id;
  }
  
  public void setId(String id) {
  this.id = id;
  }
  
  public String getFirstname() {
  return firstname;
  }
  
  public void setFirstname(String firstname) {
  this.firstname = firstname;
  }
  
  public String getLastname() {
  return lastname;
  }
  
  public void setLastname(String lastname) {
  this.lastname = lastname;
  }
  
  public String getMail() {
  return mail;
  }
  
  public void setMail(String mail) {
  this.mail = mail;
  }
  
  public Boolean getAccess() {
  return access;
  }
  
  public void setAccess(Boolean access) {
  this.access = access;
  }
  
  public Boolean getHasAccess() {
  return hasAccess;
  }
  
  public void setHasAccess(Boolean hasAccess) {
  this.hasAccess = hasAccess;
  }
  
  public Integer getIduser() {
  return iduser;
  }
  
  public void setIduser(Integer iduser) {
  this.iduser = iduser;
  }
  
  public Boolean getAccepted() {
  return accepted;
  }
  
  public void setAccepted(Boolean accepted) {
  this.accepted = accepted;
  }
  
  }
  </code></pre>
  
  <p>This is how I am adding body to the request</p>
  
  <pre><code>interface LoginApi {
          @PUT("user/abcd")
          Call&lt;abcdResponse&gt; updateabcdStatus(@Body JSONObject parent);
      }
  </code></pre>