function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
111111 

How can return the type(list or map)?

for example
 
I got the error :
Invalid return type: MAP:String,String
 
how can i get the return-value,and the return-value's type is   (list or map)?

global class listReturn {
    WebService static Map<String,String> listMethod() {
        Map<String,String> myList = new Map<String,String>();
        myList.put('ID', 'ACOO1');
        myList.put('MSG', 'Message');
        return myList;
    }
}

SuperfellSuperfell
There's no standard serialization for Map, so you can't use that as parameter or return value from a web service.
ckempckemp
My guess here would be returning the Map or List as the type Object (assuming that every Apex object inherits basic object methods like clone() and toString() from an object called Object - I've never tried this.)  When you get the returned object, you can use instanceof() to determine the object type (Map or List) and process it appropriately.