I'm trying to parse a Json response with Moshi, the problem that I have is that the value of the key is a Json wrap on a String:
{"mobile_accounts_account_showProperties":"[{\"name\": \"current\"},{\"name\": \"available\"}]"}
This is my class
@Json(name = "mobile_accounts_account_showProperties")
private List<PropertyConfig> showProperties;
I try removing the ("") with a replace("\"[", "[")
and a replace("\\", "")
before parsing but is not an option because that remove some other quotes that I do need. I try to use JsonAdapter but I can't make that work. The JsonAdapter is not getting call.
public class PropertyConfigJsonAdapter {
public PropertyConfigJsonAdapter() {
}
@ToJson
String toJson(List<PropertyConfig> card) {
return "";
}
@FromJson
List<PropertyConfig> fromJson(String object) {
return new ArrayList<>();
}
I try this to see if the JsonAdapter was getting call but it never call the "fromJson" method. Here is how I call the adapter:
MoshiConverterFactory.create(new Moshi.Builder().add(new PropertyConfigJsonAdapter()).build())