My json string looks like,
{
"userList" : {
"user" : [{
"Id" : "33",
"userId" : "raji2",
"customerId" : "35",
"username" : "raji2",
"status" : "1",
"locked" : "0",
"customAttributes" : "{\"uiPageId\":\"\",\"uiPageName\":\"\",\"uiPageViewMode\":\"Normal\"}",
"addressList" : {
"address" : ""
},
"contactList" : {
"contact" : {
"contactno" : "+919526346097",
"email" : "[email protected]"
}
},
"roleList" : {
"roleId" : "7"
},
"privilegeList" : {
"privilegeId" : ["1", "10", "11", "12", "13", "14", "15", "16", "17", "23", "24", "25", "26", "27"]
},
"entityList" : {
"entityId" : ""
}
}, {
"Id" : "34",
"userId" : "raji3",
"customerId" : "35",
"username" : "raji3",
"status" : "1",
"locked" : "0",
"customAttributes" : "{\"uiPageId\":\"\",\"uiPageName\":\"\",\"uiPageViewMode\":\"Normal\"}",
"addressList" : {
"address" : ""
},
"contactList" : {
"contact" : {
"contactno" : "+919526346097",
"email" : "[email protected]"
}
},
"roleList" : {
"roleId" : "7"
},
"privilegeList" : {
"privilegeId" : ["1", "10", "11", "12", "13", "14", "15", "16", "17", "23", "24", "25", "26", "27"]
},
"entityList" : {
"entityId" : ""
}
}
]
}
}
When I try to parse this using the sample given below and trying to take email or customerId,the data is coming as null, The code snippet I tried is:
JSONObject obj = (JSONObject) new JSONParser().parse(data);
JSONObject jsonObject = (JSONObject) obj;
System.out.println(jsonObject);
String x=(String) jsonObject.get("customerId");
System.out.println("Check Data"+x);
I used simple json library. I am getting null response.
"customAttributes"is a JSON Object embedded as a string? Meh?