If you want to pass a list object or map object to a Liferay
JSON WebService use the below code
Sending a List of
String and getting it in the ServiceLayer:
Use the below code in the ServiceImpl
public List
getList(List list){
System.out.println("list: "+list);
return list;
}
From browser use the link
like below to send the list object
http://localhost:8080/api/jsonws/MyPortlet.myview/get-list/list/["Liferay","WebSphere","SAP"]
And you can see the output like below
Sending a Map of
String,String object and getting it in the ServiceLayer:
Use the below code in the ServiceImpl
public
Map getMap(Map map){
System.out.println(map.size());
Set
keySet = map.keySet();
Iterator
itrtr = keySet.iterator();
while(itrtr.hasNext()){
System.out.println(map.get(itrtr.next().toString()));
}
return map;
}
From browser use the below link to send a Map object
http://localhost:8080/api/jsonws/MyPortlet.myview/get-map/map/{"one":"one
value","two":"two value"}
The output is displayed like below image
Comments