I am facing a problem about the GSON json to Java. I looked up many posts here, but I cannot find the solution for my question. So I list my problem here.I am trying to get the data there is a Map in json but I am not able to retrieve the data . In my log I am able to see that only this much data is coming then it throws the exception . Someone please guide me a way through. Thanks very much !
Here is my Json Data on hitting the URL from the Android app i am working on
EDIT
{
"success" : true,
"messages" : {
"success" : [
"SEARCH_QUERY_SUCCESS"
]
},
"session" : {
"id" : "cn694ivr8bmqnrveh9n8841oh7",
"expire" : "",
"YII_CSRF_TOKEN" : "4fa0ae103b547836241f5278311839b407050919"
},
"metadata" : {
"product_count" : "4458",
"category_ids" : "3",
"results" : [{
"id" : "105089",
"data" : {
"sku" : "MA851AA10ZLX",
"name" : "Alexa Mid Rise Super Skinny Leg",
"new-product" : false,
"url" : "http:\/\/theiconic.bugfoot.de\/mobile-api\/Alexa-Mid-Rise-Super-Skinny-Leg-105089.html",
"simples" : {
"MA851AA10ZLX-406437" : {},
"MA851AA10ZLX-406438" : {},
"MA851AA10ZLX-406439" : {},
"MA851AA10ZLX-406440" : {},
"MA851AA10ZLX-406441" : {},
"MA851AA10ZLX-406442" : {},
"MA851AA10ZLX-406443" : {},
"MA851AA10ZLX-406444" : {
"meta" : {
"sku" : "MA851AA10ZLX-406444",
"price" : "149.99",
"caching_hash" : "78ddaaf930f8bd0e0bf595c25643683d",
"shipment_cost_item" : "0.00",
"shipment_cost_order" : "0.00",
"tax_percent" : "10.00",
"quantity" : "2",
"cost" : "64.09",
"size_brand" : "W31\/L34",
"size" : "W31\/L34",
"size_position" : "200",
"3hours_shipment_available" : true,
"estimated_delivery" : "",
"estimated_delivery_position" : ""
},
"attributes" : {
"sort_order" : "0",
"size" : "W31\/L34"
}
}
}
}
}
]
}
}
Edit
This is my network class used for parsing
String jsonString = null;
try {
HttpGet httppost = new HttpGet(URL);
HttpClient httpClient = new DefaultHttpClient();
if (httpClient != null) {
HttpResponse response = httpClient.execute(httppost);
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
jsonString = reader.readLine();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(jsonString);
if (jsonString != null) {
Bean obj=new Gson().fromJson(jsonString, Bean.class);
Message msg = new Message();
msg.obj = obj;
responseHandler.sendMessage(msg);
//obj can be sent to a handler
}
}
}
This is Simples Bean class containing a Map
public class Simples {
private Map<String, KeyMap> keyMap;
public Map<String, KeyMap> getKeyMap() {return keyMap;}
public void setKeyMap(Map<String, KeyMap> keyMap) {this.keyMap = keyMap;}}
This is my KeyMap Bean class
public class KeyMap {
private Meta meta;
private Attributes attributes;
public Meta getMeta() {
return meta;
}
public void setMeta(Meta meta) {
this.meta = meta;
}
public Attributes getAttributes() {
return attributes;
}
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
}
}