android-apollo 中的响应无效 JSON 字符串
Invalid JSON String on response in android-apollo
我发送了简单的突变,我期待 JSON 但响应字符串是这样的:
{
facebook=https://www.facebook.com/,
linkedIn=https://www.linkedin.com/
}
如何解决?
这个好像是URL参数,用这个方法转回JSON字符串格式:
public static String urlParamsToJSON(String urlParams) {
urlParams = urlParams.replaceAll("=", "\":\"");
urlParams = urlParams.replaceAll("&", "\",\"");
return "{\"" + urlParams + "\"}";
}
object HelperJSON {
private var gson: Gson = Gson()
fun fetchSocialUrls(jsonString: String): SocialLoginUrlInfo {
Log.e("JSONHelper ", "Enter: " + jsonString)
return gson.fromJson(jsonString, SocialLoginUrlInfo::class.java)
}
fun toJsonString(simpleObject: Any?): String = gson.toJson(simpleObject)
}
在演示者中:
socialLoginUrl = HelperJSON.fetchSocialUrls(HelperJSON.toJsonString(response.data()?.socialLoginUrls()))
我发送了简单的突变,我期待 JSON 但响应字符串是这样的:
{
facebook=https://www.facebook.com/,
linkedIn=https://www.linkedin.com/
}
如何解决?
这个好像是URL参数,用这个方法转回JSON字符串格式:
public static String urlParamsToJSON(String urlParams) {
urlParams = urlParams.replaceAll("=", "\":\"");
urlParams = urlParams.replaceAll("&", "\",\"");
return "{\"" + urlParams + "\"}";
}
object HelperJSON {
private var gson: Gson = Gson()
fun fetchSocialUrls(jsonString: String): SocialLoginUrlInfo {
Log.e("JSONHelper ", "Enter: " + jsonString)
return gson.fromJson(jsonString, SocialLoginUrlInfo::class.java)
}
fun toJsonString(simpleObject: Any?): String = gson.toJson(simpleObject)
}
在演示者中:
socialLoginUrl = HelperJSON.fetchSocialUrls(HelperJSON.toJsonString(response.data()?.socialLoginUrls()))