Json string contained in String str:
{conf:{"quantity_uom":"l",price_uom:"euro",distance_uom:"km",consumption_uom:"km/l"}}
Code:
try{
if (str!=""){
this.json = new JSONObject(str);
this.quantityUom=this.json.getString("quantity_uom");
this.distanceUom=this.json.getString("distance_uom");
this.priceUom=this.json.getString("price_uom");
this.consumptionUom=this.json.getString("consumption_uom");
}
}catch (Exception e) {
throw e;
}
I have returned No value for quantity_uom. How I am doing wrong? String contain the json text.
Thank you so much.
str!=""will not work Java/Android. Use this:!str.equals("")