我在这里完全空白 - 在 gson 中解析时没有方便的方法来处理空格?我遇到以下异常:
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $
这是我的代码:
jsonArray.add(new JsonParser().parse(id));
其中 id 是带有空格的字符串,例如 Hello World
最佳答案
Hello World 不是有效的 JSON,是吗?不应该是类似 { "Hello World"} 或 { "Something": "Hello World"}
关于java - 在带有空格的字符串上使用 GSON JsonParser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32055648/