I am passing a json string to this class.

Then I try this:

Account jsonRes = (Account) JSON.deserialize(jsonString, Account.class);

I get this error:

Error: Compile Error: Method does not exist or incorrect signature: [String].deserialize(String, Type) at line 43 column 41

Do I need to include this JSON class?

2 Answers 2


Be aware that this work-around was necessary because there was a String variable (type mentioned in error message) in scope that has the same name as the JSON class (ignoring case) and the variable reference is given precedence. So changing the name of that variable would also fix this and is arguably a better approach than using the namespace.

This problem of variables hiding type names comes up quite often so watch out for it.


I got it...

It was because It needed the namespace,



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .