I'm trying to convert JSON String to List of Object(ResolveInfo) using the below method,
private List<ResolveInfo> jsonStringToListOfResolveInfo(String response) {
List<ResolveInfo> list = null;
try {
Gson gson = new GsonBuilder().create();
Type listOfMyClassObject = new TypeToken<ArrayList<ResolveInfo>>() {}.getType();
list = gson.fromJson(response, listOfMyClassObject);
if (list!=null){
Log.d(TAG, "ResolveInfoList: size - "+list.size());
}else{
Log.d(TAG, "ResolveInfoList: list = gson.fromJson(response, listOfMyClassObject); is null");
}
} catch (JsonSyntaxException e) {
Log.i(TAG, "JsonSyntaxException in " + e.getMessage());
}catch (Exception e){
Log.d(TAG, "exception is : "+e.getMessage());
}
return list;
}
But, I'm getting the exception like below
Unable to create instance of interface java.lang.CharSequence. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
What is the reason for this exception ?, Thank you!