4

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

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.

4

I got it...

It was because It needed the namespace,

System.JSON.deserialize

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.