Java tutorial
//package com.java2s; import org.json.JSONObject; import org.json.JSONObject; import android.text.TextUtils; public class Main { public static float getFloat(JSONObject jsonObject, String key) { if (jsonObject == null || TextUtils.isEmpty(key)) { return -1F; } try { return (float) jsonObject.getDouble(key); } catch (Exception e) { } return -1F; } }