[SalesForce] Can you pass a Map into a RemoteAction

I have an instance where I am trying to pass a dynamic number of Page Parameters into an action method. It works… but it only will pass as a String. Is there a way to pass correclty as a Map? (The String version clearly looks like it was meant to be a Map but when passing as a Map I get an error saying that it was passing a String.)

An acceptable alternative would also be an easy way to convert Strings to Maps but I would prefer being able to directly pass a Map.

Best Answer

I ended up using JSON to parse it:

String jsonPageParams{get; private set;}

...

  jsonPageParams = JSON.serialize(currPageParams);

...

  Map<String, Object> parsedParams = (Map<String, Object>)JSON.deserializeUntyped(jsonPageParams);

I had to use a Map of String, Object for some reason even though it's technically a Map. I just have to cast the result to a String whenever I get the value.