public with sharing class jsonAccount {
list
System.debug(JSON.serialize(accList));
AccountNameList = JSON.serialize(accList);
}
Output:
USER_DEBUG [2]|DEBUG|[{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBXIA0″},”Id”:”001U0000002LdBXIA0″,”Name”:”GenePoint”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBYIA0″},”Id”:”001U0000002LdBYIA0″,”Name”:”United Oil & Gas, UK”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBZIA0″},”Id”:”001U0000002LdBZIA0″,”Name”:”United Oil & Gas, Singapore”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBaIAK”},”Id”:”001U0000002LdBaIAK”,”Name”:”Edge Communications”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBbIAK”},”Id”:”001U0000002LdBbIAK”,”Name”:”Burlington Textiles Corp of America”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBcIAK”},”Id”:”001U0000002LdBcIAK”,”Name”:”Pyramid Construction Inc.”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBdIAK”},”Id”:”001U0000002LdBdIAK”,”Name”:”Dickenson plc”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBeIAK”},”Id”:”001U0000002LdBeIAK”,”Name”:”Grand Hotels & Resorts Ltd”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBfIAK”},”Id”:”001U0000002LdBfIAK”,”Name”:”Express Logistics and Transport”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBgIAK”},”Id”:”001U0000002LdBgIAK”,”Name”:”University of Arizona”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBhIAK”},”Id”:”001U0000002LdBhIAK”,”Name”:”United Oil & Gas Corp.”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBiIAK”},”Id”:”001U0000002LdBiIAK”,”Name”:”sForce”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002bHvsIAE”},”Id”:”001U0000002bHvsIAE”,”Name”:”AAA Copr”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000005sN4LIAU”},”Id”:”001U0000005sN4LIAU”,”Name”:”Test BBB”}]