samedi 21 septembre 2019

Can i know if an object is a custom object?

I am writing an annotation processor and i need to scan all classes with certain annotation to get all fields and create json object with same structure of the class.

For example:

public class Person {
    private String name;
    private String surname;

    /*getter and setter*/
}

My output is:

{
    "name": "string",
    "surname": "string"
} 

Now i am wondering how can i handle classes like this one:

public class PhoneNumber {
    private String countryCode;
    private String phoneNumber;

    /*getter and setter*/
}

public class Person {
    private String name;
    private String surname;
    private PhoneNumber phoneNumber;

    /*getter and setter*/
}

i would like get output like this:

{
    "name": "string",
    "surname": "string",
    "phoneNumber": {
        "countryCode": "string",
        "phoneNumber": "string"
    }
}






Aucun commentaire:

Enregistrer un commentaire