私のクラス:
public class MyClass {
public HashMap<Integer, HashMap<String, PointFMP[] >> matchingPages;
public static class PointFMP{
public float x;
public float y;
}
}
私のJson:
{
"matchingPages": {
"1": {
"Butter": [
{
"x": 16.23,
"y": 21.11
},
{
"x": 18.18,
"y": 26.67
}
],
"Cake": [
{
"x": 13.23,
"y": 21.11
}
]
},
"2": {
"Other value": [
{
"x": 41.98,
"y": 47.62
}
]
}
}
}
解析:
Gson gson = new GsonBuilder().create();
MyClass response = gson.fromJson(jsonString, MyClass.class);
私のエラー:
11-29 12:56:47.017:W / System.err(8169):com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:BEGIN_OBJECTが必要ですが、1行目1列目がSTRINGでした11-29 12:56:47.022 :W / System.err(8169):com.google.gson.internal.bind.ReflectiveTypeAdapterFactory $ Adapter.read(ReflectiveTypeAdapterFactory.java:176)
それを適切に解析する方法はありますか?
入力が有効なJsonではありません。次のようになります。
{
"1": {
"Butter": [
{
"x": 16.23,
"y": 21.11
},
{
"x": 18.18,
"y": 26.67
}
]
},
"2": {
"Butter": [
{
"x": 41.98,
"y": 47.62
}
]
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加