I have a class:Person
class Person{
String name;
String age;
}
I want to translate a Person list to jsonArray, but only the name field in the result. However, if i use
List<Person> persons = new ArrayList<Person>();
persons.add(new Person("Jack","12"));
JSONArray result = JSONArray.fromObject(persons);
result will include the age field.
What can i do?
My solution is util function createJsonObjects, using: