0
在Web服務調用中,如果響應是包含單個元素的列表,則REST Web服務返回JSON對象而不是JSON數組。我怎樣才能總是返回一個數組?其他Web服務不返回JSON數組
@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
}
實施例:具有當
JSON對象輸出一個對象具有多個對象時
{"childRequest":{"childName":"test123Child","childUserName":"add"}}
JSON對象陣列輸出:
{"childRequest":[{"childName":"Child ONE","childUserName":"chlid1"},{"childName":"abayakoon","childUserName":"abey"}]}