I am trying to save the state of some labels on an Xamarin.Forms App. I am following the steps of Creating Mobile Apps with Xamarin.Forms book, it shows how to store value per value but recommends this for when you have several info:
An application with many more items might want to consolidate them in a class named AppSettings (for example), serialize that class to an XML or a JSON string, and then save the string in the dictionary.
I am lost about how to do it, I created a simple class
class AppSettings
{
    public double? gain = null;
    public string mainTitle = "my title";
}
In my constructor I recover the properties in this way
      //! Recover appSettings if some
        IDictionary<string, object> properties = Application.Current.Properties;
        if (properties.ContainsKey("mainTitle"))
        {
            mainTitle.Text = properties["mainTitle"] as string;
        }
        //! New code for loading previous keypad text.
        App app = Application.Current as App;
        mainTitle.Text = app.MainTitle;
And the event that I use to save it is:
void onHomeOptionButtonClicked(object sender, EventArgs args)
        {
            Button buttonClicked = (Button)sender;
            mainTitle.Text =  buttonClicked.Text;
            // !Save keypad text.
            App app = Application.Current as App;
            app.MainTitle = mainTitle.Text;
        }
What I do not know is how to structure my Class so it can be serialized to JSON (I also do not know how to do this serialization)
I wanted to create a class in C# with this Javascript's idea:
myAppSettings = {
    HomePage : {
        name1 : "value1",
        name2 : "value2"
        name3 : {
            name3.name1 : "value3.1"
        }
    },
    OtherPage:{
        name1 : "value1",
        name2 : "value2"
    },
    .
    .
    .
};
Which is the correct way to do it in C#?
 
    