JSON:
[
{
"name": "TEST",
"desc": "",
"descData": null,
"closed": false,
"idOrganization": null,
"idEnterprise": null,
"limits": null,
"pinned": null,
"shortLink": "0vww",
"powerUps": [],
"dateLastActivity": "2020-02-20T17:35:34.008Z",
"idTags": [],
"datePluginDisable": null,
"creationMethod": null,
"ixUpdate": null,
"enterpriseOwned": false,
"idBoardSource": "1232131",
"id": "1231231123",
"starred": false,
"url": "test",
"prefs": {
"permissionLevel": "private",
"hideVotes": false,
"voting": "disabled",
"comments": "members",
"invitations": "members",
"selfJoin": false,
"cardCovers": true,
"isTemplate": false,
"cardAging": "regular",
"calendarFeedEnabled": false,
"background": "5c2f9de25f4d0845100f81b3",
"backgroundImage": "TEST",
"backgroundTile": false,
"backgroundBrightness": "light",
"backgroundBottomColor": "#635e5d",
"backgroundTopColor": "#f4f4f3",
"canBePublic": true,
"canBeEnterprise": true,
"canBeOrg": true,
"canBePrivate": true,
"canInvite": true
},
"subscribed": false,
"labelNames": {
"green": "",
"yellow": "",
"orange": "",
"red": "",
"purple": "",
"blue": "",
"sky": "",
"lime": "",
"pink": "",
"black": ""
},
"dateLastView": "2020-05-24T20:26:00.621Z",
"shortUrl": "https://trello.com",
"templateGallery": null,
"premiumFeatures": []
}
]
The below code fails when trying to extract user preferences node-
System.out.println("User Preferences are below: \n");
LinkedHashMap <String,String> tmplist = new LinkedHashMap<>();
tmplist.putAll(js.get("prefs"));
Iterator<String> itr = tmplist.keySet().iterator();
while (itr.hasNext())
{
String key = itr.next();
System.out.println(key+""+tmplist.get(key)); // ---- Fails here. java.util.LinkedHashMap
//cannot be cast to java.lang.String
}
Do not want to manually extract values as below String colorblind = js.get("prefs.colorBlind").toString(); System.out.println("Color Blind is "+colorblind);
Please suggest how can I fix the code such that I can extract the complete preferences.