Serialization with Gson

Report a typo

How can we use the gson object given below to convert our MySpecialClass instance, msc, into a JSON String? Enter the code that is missing. Do not include a ;.

class MySpecialClass {
    // fields
    // methods
    // constructor

    public static void main(String[] args) {
        Gson gson = new Gson();
        MySpecialClass msc = new MySpecialClass();

        String mySpecialString = ____________;      // Fill in this blank
    }
}
Enter a short text
___

Create a free account to access the full topic