-2

示されているように有効なjsonがあります

{

    "Items": "{one,two,three}"
}

ObjectMapper を使用して、これを ArrayList にマップする必要があります。

しかし、その値を設定していない、私に知らせてください。

私はこの方法を試しました

public class Hi {
    private static JsonHelper jsonHelper = JsonHelper.getInstance();

    public static void main(String[] args) throws Exception {

        ObjectMapper mapper = new ObjectMapper();
        MyList yourData = mapper.readValue(new File("yourdata.json"),
                MyList.class);

    }

}


public class MyList {

    private ArrayList<String> Items= new ArrayList<String>();
    // setters and getters 

}
4

2 に答える 2

2

"{one,two,three}" は json のリストを表していません。["one", "two", "three"] は 3 つの要素のリストです。

于 2013-02-06T13:01:19.207 に答える
0

jsonは次のようになります

{"test": "test"、 "items":["one"、 "two"、 "three"]}

于 2013-02-06T13:08:53.033 に答える