+ Start a Discussion
sobroachsobroach 

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?

Best Answer chosen by Admin (Salesforce Developers) 
sobroachsobroach

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

Cory CowgillCory Cowgill

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.

Cory CowgillCory Cowgill

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.

sobroachsobroach

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

sobroachsobroach

I'm using eclipse.

sobroachsobroach

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);

    }   

This was selected as the best answer
Cory CowgillCory Cowgill

I see while I was typing you solved it. Cool. :)

sobroachsobroach
Thanks! happy coding