You need to sign in to do that
Don't have an account?
sobroach
Deserialize a list of strings to an @future method using JSON.deserialize
Trying to deserialize a list of programming objects to an @future method and I'm getting this error:
Method does not exist or incorrect signature: JSON.deserialize(LIST<String>, Type)
@Future(callout=true)
public static void send(List <String> mgs){
List<ProgrammingObject> messages = (List<ProgrammingObject>)JSON.deserialize(msgs, List<ProgrammingObject>.class);
Any help?
I solved my problem by going through one by one
@Future(callout=true)
public static void send(List <String> msgString){
List<ProgrammingObject> messages = new List<ProgrammingObject>();
for(String s: msgString)
{
messages = (List<ProgrammingObject>)JSON.deserialize(s, List<ProgrammingObject>.class);
}
All Answers
JSON is fairly new to the Apex Libarary. What is the version of your APEX Classes? Make sure it is using the latest version, or at least 27.
Also if you are doing this in the Force.com IDE make sure to update your Force.com IDE so that it sees latest versions for compiling.
wassup Cory!
Yeah - I know json is new and our api version was 26 and just updated to 27. Any advice on the code I wrote?
Sonja
I'm using eclipse.
I solved my problem by going through one by one
@Future(callout=true)
public static void send(List <String> msgString){
List<ProgrammingObject> messages = new List<ProgrammingObject>();
for(String s: msgString)
{
messages = (List<ProgrammingObject>)JSON.deserialize(s, List<ProgrammingObject>.class);
}
You can't pass List<String> to deserialze. You need to pass each String.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_json.htm
http://salesforce.stackexchange.com/questions/4872/use-json-serialization-to-get-around-parameter-limitations-for-future-methods
I see while I was typing you solved it. Cool. :)