我想将 Json 解组为 Map/List of Strings(例如 Map>...)
这是我的输入:
{"pointsOfSale":
{"pointOfSale":[
{"href":"\/pointsOfSale\/UUID.0abc2aca-7930-4c9e-9f38-8af3d0692e04",
"model":{"href":"\/models\/modelePointOfSale",
"modelType":{"href":"\/modelTypes\/pointOfSale"}},
"source":{"href":"\/sources\/TEST"},
"attribute":[
{"code":"pointOfSalePhysical","value":true},
{"code":"mail","value":"Mail1"},
{"code":"adresse","value":"address1"}]},
{"href":"\/pointsOfSale\/UUID.a12e7adf-652a-4197-91bf-d4785e43f09f",
"model":{"href":"\/models\/modelePointOfSale",
"modelType":{"href":"\/modelTypes\/pointOfSale"}},
"source":{"href":"\/sources\/Wikeo"},
"attribute":[
{"code":"pointOfSalePhysical","value":false},
{"code":"mail","value":"Mail1"},
{"code":"adresseMateriau","value":"Material address1"}]}
}}
我希望能够在解组后做这样的“事情”:
myJsonMapped.get("pointsOfSale").get("pointOfSale").get(0).get("source").get("href").equals("\/sources\/TEST") == true
例如,使用 Gson 我们可以进行这种解码:
new Gson().fromJson(json, Map.class);
我知道我可以用一个简单的 bean 或处理器等来做到这一点......
我只是想知道我可以使用本机 JSON 骆驼组件配置更有效地做到这一点
编辑:我已经尝试了不同的东西: unmarshal().json()... 或 unmarshal().json(JsonLibrary.Gson, Map.class).. etc... 没有成功:'(