Problem in converting Java ArrayList with one element to JSON Object
I have developed rest web service to get the JSON object list. When there is more than one objects rest web service return me correct JSON array. But if there is only one object to return Rest web service not returning an JSON array. I want to get JSON array for all the time.
My rest service method
@GET
@Produces("application/json")
@Path("/chekinList")
public List<LocationReguest> getChekinList(@QueryParam("childID") String userName, @QueryParam("appkey") String appkey, @QueryParam("appPassword") String appPassword) {
LocationController locationController = new LocationController();
List<LocationReguest> locreqlist = locationController.getChekinLi开发者_C百科st(userName);
//TODO return proper representation object
return locreqlist;
}
JSON Object return when having one object {"childRequest":{"childName":"test123Child","childUserName":"add"}}
JSON Object array return when having more object
{"childRequest":[{"childName":"Child ONE","childUserName":"chlid1"},{"childName":"abayakoon","childUserName":"abey"}]}
Please help me to get solve this
see http://www.flittn.com/blog/?p=146 for a workaround
精彩评论