java如何将JSONObject转成实体对象
import com.google.gson.Gson; import org.json.JSONObject; // ... JSONObject json = new JSONObject("{\"name\":\"John Smith\",\"age\":30}"); Gson gson = new Gson(); Person person = gson.fromJson(json.toString(), Person.class);
import com.google.gson.Gson; import org.json.JSONObject; // ... JSONObject json = new JSONObject("{\"name\":\"John Smith\",\"age\":30}"); Gson gson = new Gson(); Person person = gson.fromJson(json.toString(), Person.class);