What I am trying to do is create a
public JSONObject(java.lang.Object object, java.lang.String names)
you have two choices,
a. if you want to stick with the standard org.gson libraries, you can write your own
public static MyObject fromJson(String json) public String toJson()
methods for each model object. the implementation of each must use the org.json library to populate the fields of the object, and to build a JSON and from the object's fields, respectively.
b. use GSON or jackson that by design will perform object binding. GSON is simpler, jackson is faster.
really, i did a performance eval of all three, and it went 1. org.json, jackson, and gson, with gson being ~10x slower. it's not really fair to compare org.json however because it doesn't include object binding code.
if you have a simple flat model object with direct mapping to json, they are both brain dead simple. if you want custom mappings or have complex structures, you will need to read the docs and write some custom serialization / deserialization code.