I have the following code:
fieldList = (List<Object>)JSON.deserializeUntyped('['+ JSONValueRights +']');
for(Object fld : fieldList){
Map<String,Object> data = (Map<String,Object>)fld;
RightsTrackerListValue.Add(new Rights_Tracker__c(Category__c = (String)data.get('category'), Product__c = (String)data.get('product'), Details__c = (String)data.get('details'), Agreement__c = Decimal.valueOf(data.get('agreement'))));
}
I'm trying to get the agreement to be converted to a decimal.
Looking at the following page I can see that decimal has a method called .valueOf where I can pass a string and get it converted to decimal.
However I get the error 'decimal does not exist'. What am I doing wrong?
Best Answer
You should convert the
Object
toString
first. And thenString
toDecimal
:In the Decimal docs: the
valueOf(...)
method can take as parameter:but not the
Object
!So in your code use: