-3

I have read many posts regarding this but I m not able to to deserialize the data . So please can anyone help me with it. serialized data:

"fieldlist" : JSON.stringify(selfield)

but I m not able to deserilaize it and also store it to list.

/Apex class:/

 String lststr;
 lststr=(string)JSON.deserialize(fieldlist,String.class);
 System.debug('lststr'+lststr);
 List<String> lstAlpha = fieldlist.split(',');
 System.debug('lstAlpha'+lstAlpha);

This is the code I am trying but there is no value coming in lststr

fieldlist["name","isdeleted"]

This is the form of my fieldlist value Any suggestions are welcome

  • For this to work your input JSON must be of the form (including quotes) "a, b, c". If the quotes are missing (these can be single or double quotes) then it isn't a JSON string and won't parse into a string. Additionally, you then split the "fieldlist" by commas, rather than using the lststr. Please edit your question to include things like what the fieldlist value looks like. – Phil W Oct 22 '19 at 14:04
  • fieldlist["name","isdeleted"] in this form I m getting my data in fieldlist – maria Oct 22 '19 at 14:12
  • what type of data is coming if you put debug log like system.debug('before:'+fieldlist); – sdandamud1 Oct 22 '19 at 14:15
  • same data is coming and after deserialize it is empty – maria Oct 22 '19 at 14:16
1

I think you want something like this:

String fieldlist = '["name","isdeleted"]';

String[] lststr;

lststr=(string[])JSON.deserialize(fieldlist,List<String>.class);

System.debug('lststr'+lststr);
| improve this answer | |
  • Thank you so much – maria Oct 22 '19 at 14:23

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.