我一直在看这个问题似乎无法解决这个问题。我有一个时间敏感的截止日期,所以如果有人有任何关于为什么会发生这种情况的建议会有所帮助!
JSON结果:
{"py/object": "obj", "values": [63542, 56866, 47790, 62456, 49279, 43555, 45195, 59769, 58949, 59286, 54615, 48464, 53866, 56288, 55735, 45681, 62780, 61144, 49164, 60120, 55973, 49670, 58078, 49363, 48753, 52036, 47628, 57778, 60026, 56987, 60179]}
JAVA模型:
public class Obj implements Serializable {
protected static class JSON_FIELDS {
public static final String VALUE_LIST = "values";
}
@SerializedName(JSON_FIELDS.VALUE_LIST)
public Integer[] valuesReturned;
}
解析代码:
Gson gson = new Gson();
InputStream inputStream = new ByteArrayInputStream(
result.getBytes(Charset.defaultCharset()));
Reader reader = new InputStreamReader(inputStream);
Obj vals = gson.fromJson(reader, Obj.class);
但是我收到以下错误:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
我不确定字符串/对象混淆发生在哪里,对我来说是否正确?
谢谢!