Hello,
I was trying to fetch a document from Couchbase Server. It had a key with all caps. for e.g. : “PIN”
I was not able to fetch data for this specific key. All other keys data was coming fine.
I tried changing to small letters and it works. But the thing is all CAPS is not working.
I might be wrong, please correct.
Here is my JSON present in db.
{
“email”: “abdul@abc.com”,
“id”: “9cf04730-128e-11ea-8e50-bb3952ffc321”,
“modelName”: “user”,
“name”: “Abdul Ghani”,
“password”: “$2a$10$TG1nW.cvFvUtyTaTz3IivO2PCLsulQyKV35G6gqslJvFzwdEt5Ioa”,
“PIN”: “123456”,
“role”: “tenantUser”,
“tenantId”: “900496d0-128d-11ea-8e50-bb3952ffc320”,
“username”: “abdulghani”
}
Notice the key “PIN” in above document.
Here is my java class to map JSON objects to Java.
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class WayshipUser implements Parcelable {
@SerializedName("PIN")
@Expose
private String PIN;
@SerializedName("email")
@Expose
private String email;
@SerializedName("id")
@Expose
private String id;
@SerializedName("modelName")
@Expose
private String modelName;
@SerializedName("name")
@Expose
private String name;
@SerializedName("password")
@Expose
private String password;
@SerializedName("role")
@Expose
private String role;
@SerializedName("tenantId")
@Expose
private String tenantId;
@SerializedName("username")
@Expose
private String username;
public WayshipUser() {
}
public String getPIN() {
return PIN;
}
public void setPIN(String PIN) {
this.PIN = PIN;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String toString() {
return this.name; // To display in the Spinner list.
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.PIN);
dest.writeString(this.email);
dest.writeString(this.id);
dest.writeString(this.modelName);
dest.writeString(this.name);
dest.writeString(this.password);
dest.writeString(this.role);
dest.writeString(this.tenantId);
dest.writeString(this.username);
}
protected WayshipUser(Parcel in) {
this.PIN = in.readString();
this.email = in.readString();
this.id = in.readString();
this.modelName = in.readString();
this.name = in.readString();
this.password = in.readString();
this.role = in.readString();
this.tenantId = in.readString();
this.username = in.readString();
}
public static final Creator<WayshipUser> CREATOR = new Creator<WayshipUser>() {
@Override
public WayshipUser createFromParcel(Parcel source) {
return new WayshipUser(source);
}
@Override
public WayshipUser[] newArray(int size) {
return new WayshipUser[size];
}
};
}