I am trying to store JSON data into a POJO class and then store the class into Firebase. If I use str1 as input to fromJson the pojo class is populated properly, but if str2 is used fromJson returns null. Question is which of the two strings(str1 or str2) is correct ? My original data is in CSV format and I used one of the online converters to convert the CSV file to JSON format. The data is identical to the format shown in str2.
String str1 = "{\"code\":602,\"desc\":\"somedescription\"}";
String str2 = "{"code":602,"desc":"somedesc"}";
myGson = new Gson();
codeDescMast = myGson.fromJson(str1,CodeDescMast.class);
This is my POJO class.
public class CodeDescMast {
int code;
String desc;
public CodeDescMast() { }
public CodeDescMast(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
regards jana