In the web service call, if the response is a list containing a single element, the REST web service returns a JSON object instead of a JSON array. How can I always return an array?
@GET
@Produces("application/json")
@Path("/chekinList")
public List<LocationReguest> getChekinList(@FormParam("childID") String userName,@FormParam("appkey") String appkey,@FormParam("appPassword") String appPassword) // Getting the list of check in list
{
LocationController locationController = new LocationController(); //Controller object
List<LocationReguest> locreqlist = locationController.getChekinList(userName); //Calling controller function
return locreqlist; //return proper representation object
}
Example:
JSON Object output when having one object
{"childRequest":{"childName":"test123Child","childUserName":"add"}}
JSON Object array output when having more objects:
{"childRequest":[{"childName":"Child ONE","childUserName":"chlid1"},{"childName":"abayakoon","childUserName":"abey"}]}