我的输入中只有一个列表,共13个HashMap。每个HashMap仅具有2个键“ fieldName”和“ accessibilityType”以及相应的值:
"fieldAccessibility": [
{
"fieldName": "firstName",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "lastName",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "avatarUrl",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "username",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "birthDate",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "phoneNumbers",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "email",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "language",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "externalId",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "externalCode",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "punchBadgeId",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "minor",
"accessibilityType": "EDITABLE"
},
{
"fieldName": "seniorityDate",
"accessibilityType": "EDITABLE"
}
]
我试图通过它进行迭代,并将“ accessibilityType”的值更改为“ READ”,其中“ fieldName”是“ birthDate”。有人可以说一种有效的方法来做到这一点。到目前为止,这是我尝试读取和打印每个键值对的尝试:
final List<HashMap<String, String>> list = some code to get the input;
for (HashMap<String, String> m : list)
{
for (HashMap.Entry<String, String> e : m.entrySet())
{
String key = e.getKey();
String value = e.getValue();
System.out.println("SEE HERE TEST " + key + " = " + value);
}}
蝴蝶刀刀
相关分类