0
繼我的previous question之後,我可以返回自定義屬性部分中的組列表,但是我想知道我需要做什麼才能將它們返回到std JSON結構中。在customAttributes中返回JSON數組
如果我發回一個Java列表
HashMap<String, Object> customAttributes = new HashMap<String, Object>();
customAttributes.put("AuthenticationDate", new Date());
List<String> groups = new ArrayList<String>();
groups.add("Users");
groups.add("Managers");
customAttributes.put("Groups", groups);
UserIdentity identity = new UserIdentity(loginModule, USERNAME, "Fred Flintstone", null, customAttributes, PASSWORD);
然後客戶端收到
{"Groups":"[Users, Managers]","AuthenticationDate":"Tue Nov 26 12:07:37 EST 2013"}
如果我在一個HashMap
List<Map<String, Object>> groups = new ArrayList<Map<String, Object>>();
HashMap<String, Object> groupMap1 = new HashMap<String, Object>();
groupMap1.put("id", "Users");
groups.add(groupMap1);
HashMap<String, Object> groupMap2 = new HashMap<String, Object>();
groupMap2.put("id", "Managers");
groups.add(groupMap2);
customAttributes.put("Groups", groups);
UserIdentity identity = new UserIdentity(loginModule, USERNAME, "Fred Flintstone", null, customAttributes, PASSWORD);
我得到以下響應添加組客戶端
"attributes":{"Groups":"[{id=Users}, {id=Managers}]","AuthenticationDate":"Tue Nov 26 12:13:40 EST 2013"}
我真的很想得到的是這樣的
"attributes":{"Groups":[{"id" : "Users"}, {"id" :"Managers"}],"AuthenticationDate":"Tue Nov 26 12:13:40 EST 2013"}