I want to convert string into Map so I can get key and values from it for example:
String fields = '[{"Title":"Name"},{"Product_type":"IsActive"}]';
convert into map and get the value
system('Value '+ map.get(Title));
system('Value '+ map.get(Product_type));
How to do this?
Best Answer
Just to add on @sfdcfox answer, you can still use
JSON.deserializeUntyped
but first you will need to convert toList<Object>
to prevent the errorInvalid conversion from runtime type List<ANY> to Map<String, ANY>
After converting to List, you can build the map as follows: