Better code for saving user details through JSON?

Hi
I want to know what is the best way to save a lot of properties like firstname lastname dob etc. What i normally do is create a property for every data to fetch and initialize with empty value. Then create a shared instance of that and at the time of parsing I overwrite each value.
It looks like very much redundant. Is there any better approach to do this. Creating an initializer of that big is also looks hectic to read and create.

@amberk94. Thanks very much for your question, and my apologies for the delayed response!

Typically, when parsing JSON objects from the web, what you should do is create a struct or class that defines whatever properties you’re receiving from the web. Typically, it would be a JSON object containing a collection of records that could be grouped together into a particular type. In your case, it seems like you’re downloading details for a particular person, so what you should do is create a struct of type “Person”, with the properties that you mentioned above (e.g. firstName, lastName, DOB, etc.). After you download the JSON object, you iterate through it, creating the necessary number of Person objects, and then store them in an array, or any other collection. Once you have this collection, you would go ahead and deal with the data as you please. :slight_smile:

I hope this helps!

All the best!