-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

4
  • 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
    Commented Oct 22, 2019 at 14:04
  • fieldlist["name","isdeleted"] in this form I m getting my data in fieldlist
    – maria
    Commented Oct 22, 2019 at 14:12
  • what type of data is coming if you put debug log like system.debug('before:'+fieldlist);
    – sdandamud1
    Commented Oct 22, 2019 at 14:15
  • same data is coming and after deserialize it is empty
    – maria
    Commented Oct 22, 2019 at 14:16

1 Answer 1

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);
1
  • Thank you so much
    – maria
    Commented Oct 22, 2019 at 14:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .