I hava a pojo with lots of classes attached to it. Wanted to know the JSON structure to be passed to the API.
Is there any way to create the json structure (with some fake data)?
Example:
public class Staff {
private String personName;
private Salary salary;
private String[] position; // Array
private List<Department> department; // List
private Map<String, Address> addressMap; // Map
// getters & setters of those too.
}
- The
Department
has more number of POJOs within it (person joining to the department data) Salary
has rivisions of each designations.- so and so.
I am trying to get a JSON struture of this without creating it manually.
Something like this (Expected output)
{
"person_name": "person_name",
"salary": {
"joining_salary": "0",
"designation": {
"joining_designation": "joining_designation",
"some_data": "some_data"......
}
},
"department": {
"current_department": {
"latitude": 59.331132099999998,
"longitude": 18.066796700000001,
"address": {
"address_line": "address_line",
"city_name": "city_name",
"zip_code": "zip_code",
"country_code": "co" ....> Restricted to 2 charactors
}
}
},
"some_other": [
"...."
],
"some": "some"
}
You can use the
com.google.code.gson
libraryMaven dependency is as below
You can try the following,