1. Course
  2. Data serialization
  3. JavaScriptSerializer: Serialize objects

JavaScriptSerializer: Serialize objects


Last updated: 8/23/2020 Difficulty: Intermediate

Create a C# program that serialize and deserialize objects in JSON format. To do this, you can use the JavaScriptSerializer class included in the System.Web.Extensions namespace.

First implement a Person class with three properties (Name, Age and City). The City class will have two properties (Name and Population). Then create a person object and use the serializer of the JavaScriptSerializer object to save the data in file.json, later deserialize the file.json and print it on the screen. Remember to prepare a ToString() method to print the Person class.

Input


                    
                    

Output



                    

Solution

Data serialization

3 / 5

Android App


Practice C# anywhere with the free app for Android devices.

Android App

Exercises C# by difficulty


Learn C# at your own pace, the exercises are ordered by difficulty.

Make a donation


Your donations support our work and contribute to the maintenance of the app.

Advertising