示例
import org.json.*; public class JSONObjectTypeValuesTest { public static void main(String[] args) throws JSONException { JSONObject jsonObj = new JSONObject( "{" + "Name : Adithya," + "Age : 22, " + "Salary: 10000.00, " + "IsSelfEmployee: false " + "}" ); System.out.println(jsonObj.getString("Name")); // returns string System.out.println(jsonObj.getInt("Age")); // returns int System.out.println(jsonObj.getDouble("Salary")); // returns double System.out.println(jsonObj.getBoolean("IsSelfEmployee")); // returns true/false } }
Adithya 22 10000.0 false
以上就是如何在Java中从JSON对象中获取不同类型的值?的详细内容,更多请关注php中文网其它相关文章!
已抢186859个
抢已抢67390个
抢已抢353417个
抢已抢667847个
抢已抢123079个
抢已抢24684个
抢