JAVA JSONObject.toBean() 方法使用

JAVA JSONObject.toBean() 方法使用


一、方法简介

JSONObject.toBean() 方法意为:从JSONObject 对象转换为 JAVA 对象。


二、导包

import org.json.JSONObject; 


二、用法

// json string

String egJoStr="{stuId:101,stuName:'mack',stuAge:17,stuSex:'1'}";

// to JSONObject

JSONObject egJo=JSONObject.formObjct(egJoStr);

// to java bean

Student stu= (Student)JSONObject.toBean(egJo,Student.class);

你可能感兴趣的:(JAVA,JSONObject)