Hi all am having trouble in parsing the json which as single quote(') and & inside one string value am getting following error.
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 187 path $[0].productName
Now let me tell what i have tried so far am using gson for parsing json which am getting above error, this is the json am trying to parse
[
{
"productName":"PETER'S Cheese & Onion Slice",
"ref_Products_Display_Name":"",
"ref_Products_Description":"",
"ref_Product_Brand_Id":"",
"ref_Category_Id":"NFz3N19vVGaGh1Uhxx8V",
"ref_Sub_Category_Id":"5TLxySL5qWWSQh3C0BFV"
}
]
Code am trying to parse:
var args: String = call.argument("data")!!
val gson = GsonBuilder().setPrettyPrinting().disableHtmlEscaping() .create()
args = args.replace("\\\"", "'");
args.replace("'","");
val productList = gson.fromJson<ArrayList<OrderDetail>>(args.substring(1, args.length - 1),
object : TypeToken<ArrayList<OrderDetail>>() {}.type)
OrderDetailModel
public class OrderDetail{
String productName;
String ref_Products_Display_Name;
String ref_Products_Description;
String ref_Product_Brand_Id;
String ref_Category_Id;
String ref_Sub_Category_Id;
}
Can someone let me know how to parse the above json and thanks in advance!!!