I am trying to deserialize a JSON response.
public class CLiveExMarketPriceHistory{
public String lwin11; //11227502005
public String lcurrency; //GBP
public String priceFrom; //2013-07-12
public cls_prices[] prices;
public class cls_prices {
public String ldate; //2013-07-12
public Decimal marketPrice; //880
}
public static CLiveExMarketPriceHistory parse(String json){
return (CLiveExMarketPriceHistory) System.JSON.deserialize(json, CLiveExMarketPriceHistory.class);
}
The JSON response is
{"lwin11":"11227502005","currency":"GBP","priceFrom":"2013-07-12","prices":[{"date":"2013-07-12","marketPrice":880.0},{"date":"2013-07-13","marketPrice":880.0},{"date":"2013-07-14","marketPrice":880.0},{"date":"2013-07-15","marketPrice":880.0},{"date":"2013-07-16","marketPrice":880.0},{"date":"2014-01-28","marketPrice":950.0}]}
The issue I am facing is that the JSON has attributes like date and currency which i am not able to use in my class as they are salesforce datatypes. I tried changing the class variables as lcurrency and ldate. But after deserialisation the values for these changed class variables are null as they don't match with the JSON response.
Any thoughts on how i can get values for the date and currency from JSON?
date. – Mike Chale Jan 28 '14 at 15:07