Hi. I want utility that generates classes from JSON. For example we got
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York"
}
We pass this to our util and on exit we have something like this:
class Address {
JSONObject mInternalJSONObject;
Address (JSONObject json){
mInternalJSONObject = json; }
String getStreetAddress () {
return mInternalJSONObject.getString("streetAddress"); }
String getCity () {
return mInternalJSONObject.getString("city"); }
}
class Person {
JSONObject mInternalJSONObject;
Person (JSONObject json){
mInternalJSONObject = json; }
String getFirstName () {
return mInternalJSONObject.getString("firstName"); }
String getLastName () {
return mInternalJSONObject.getString("lastName"); }
Address getAddress (){
return Address(mInternalJSONObject.getString("address")); }
}
Not so hard to write, but I'm sure somebody already did it.