一些json字段没有被json对象解析

时间:2012-12-12 21:36:04

标签: android tastypie

我能够从tastypie休息服务中接收json响应。我现在遇到的问题是从json对象中获取单个值。这是问题

a={"pincode":"7593836483048364830843","id":"5","resource_uri":"\/api\/oncredit\/prepaid\/5\/","amount_charged":"200","used":false,"network_type":"AIRTEL","user":"\/api\/oncredit\/user\/1\/"}

public void getJSONValue(String a){
    JSONSTRING = a;
    try { 
        JSONObject obj = new JSONObject(JSONSTRING);
        String pincode = obj.getString("pincode");
        String amount_charged = obj.getString("amount_charged"); 

    } catch (JSONException e) { 
        e.printStackTrace(); 
    } 
}

我现在面临的问题是,当debuging时,pincode的值与used,resource_url一起设置为null。我不知道为什么它被设置为null

1 个答案:

答案 0 :(得分:0)

String pincode=(String)obj.get("pincode");