“预期BEGIN_Object,但在第1列为字符串”我有这样的方法:public static Object parseStringToObject(String json) {
String Object = json;
Gson gson = new Gson();
Object objects = gson.fromJson(object, Object.class);
parseConfigFromObjectToString(object);
return objects;}我想用以下方法解析一个JSON:public static void addObject(String IP, Object addObject) {
try {
String json = sendPostRequest("http://" + IP + ":3000/config/add_Object", ConfigJSONParser.parseConfigFromObjectToString(addObject));
addObject = ConfigJSONParser.parseStringToObject(json);
} catch (Exception ex) {
ex.printStackTrace();
}}但我收到一条错误信息:JsonSyntaxException:java.lang.IllegalStateException:预期BEGIN_Object,但在第1列为String
3 回答
largeQ
TA贡献2039条经验 获得超7个赞
{
"
繁星淼淼
TA贡献1775条经验 获得超11个赞
try{ gson.fromJSON(ad, Ad.class); //...}catch (IllegalStateException | JsonSyntaxException exception){ //...
boolean failed = false;try{ gson.fromJSON(ad, Ad.class); //...}catch (IllegalStateException | JsonSyntaxException exception){ failed = true; //...}if (failed){ //...
添加回答
举报
0/150
提交
取消