[SalesForce] Method does not exist or incorrect signature: JSON.serialize(List)

My org instance is https://ap1.salesforce.com/

Looks like it is an issue.

List<String> myArray = new List<String>();
        for(Integer i=0;i<10;i++)
        {
           myArray.add('Test '+i);
           System.debug(myArray[i]);
        }

system.debug(JSON.serialize(myArray));

try to run this code in developer org..

you will get

Line: 11, Column: 14 Method does not exist or incorrect signature:
JSON.serialize(List)

I know I used this before it works before. Anyone knows why this is not working.


If we use SYSTEM.JSON.serialize(List<String>) then it works perfectly ….
Below code will work..

List<String> myArray = new List<String>();
        for(Integer i=0;i<10;i++)
        {
           myArray.add('Test '+i);
           System.debug(myArray[i]);
        }

system.debug(SYSTEM.JSON.serialize(myArray));

I used JSON.serialize() in so many VF pages. Now all the page showing this error.

Best Answer

enter image description here

This code works for me. I think you have some class with same name "JSON" and it is giving you error. After you use namespace it will works. because Namespace remove the conflict between classes. Check your organization code and if possible try to change the class name it will solve your problem.

@Update: I test this in same instance.

Related Topic