I am new to Java, and want to parse the JSON response below. I can get to ID but not able to get to startDate.. Need help.
The StratDate & EndDate are separate KEYS under (LIST VALUES) OfferDateRange but not sure how to define that in Java class.
You can check the JSON data through http://jsonviewer.stack.hu/, I am not able to paste a picture of it.
import java.util.ArrayList;
public class offers
{
private ArrayList<PkgData> pkg;
class PkgData
{
Info Info;
offerDateRange offerDateRange;
class Info
{
int Id;
}
class offerDateRange
{
String StartDate;
String EndDate;
}
public int getId() {
return Info.Id;
}
public String getStartDate() {
if (offerDateRange != null && offerDateRange.StartDate != null)
return offerDateRange.StartDate;
return "";
}
}
public ArrayList<PkgData> getpkg() {
return pkg;
}
}
JSON:
{
"offerInfo":{
"siteID":"1",
"language":"en_US",
"currency":"USD"
},
"offers":{
"pkg":[
{
"offerDateRange":{
"StartDate":[
2015,
11,
8
],
"EndDate":[
2015,
11,
14
]
},
"Info":{
"Id":"111"
},
"PricingInfo":{
"BaseRate":1932.6
},
"flt_Info":{
"Carrier":"AA"
}
}
]
}
}