4

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.

  • 3
    works perfectly in my org, you don't have a custom class called JSON do you? – Phil Hawthorn Jan 4 '16 at 12:14
9

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.

  • 1
    Yes @Tushar someone created a class with JSON name. Really yaar I dont know who is. Thanks for ans. I will accept your Ans.. – Ratan Paul Jan 4 '16 at 12:17

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.