0

私のサーバーはjsonを返し、Jacksonを使用して応答をデシリアライズしています

応答では、私は車と呼ばれるキーを持っています車の値は配列またはオブジェクトである可能性があり、どのように私のクラスを定義できますか

応答

複数のオブジェクトが存在する場合、オブジェクトの配列が返されます。それ以外の場合は、オブジェクトが返されます

{ "車":"[{obj,obj,obj}]" }

{ "車":"obj"

}

4

1 に答える 1

0

the json format you posted has no array only strings. the first is car the second is [{obj,obj,obj}]

The json should look like this: {"Car":["","",""]} and can be mapped to this java class:

public static class JsonTest extends Hashtable<String, List<String>> {
    public JsonTest(){};
}

your second json string is of a different format it should have the array notation too:

{ "Car":[ "" ] }
于 2012-12-07T08:56:13.933 に答える