Recall & Review
beginner
What is JSON and why is it commonly used in programming?
JSON (JavaScript Object Notation) is a simple text format to store and exchange data. It is easy for humans to read and write, and easy for machines to parse and generate. It is widely used for data exchange between web servers and clients.
Click to reveal answer
beginner
Which C# class is commonly used to read and write JSON files?The <code>System.Text.Json.JsonSerializer</code> class is commonly used in C# to convert objects to JSON strings and JSON strings back to objects. It helps read from and write to JSON files easily.Click to reveal answer
intermediate
How do you read a JSON file into a C# object?
You can read a JSON file by first reading the file content as a string using
File.ReadAllText, then use JsonSerializer.Deserialize<T>(jsonString) to convert it into a C# object of type T.Click to reveal answer
intermediate
How do you write a C# object to a JSON file?
Use
JsonSerializer.Serialize(object) to convert the object to a JSON string, then write it to a file using File.WriteAllText. This saves the object data in JSON format.Click to reveal answer
intermediate
What is the importance of matching C# class structure with JSON data?The C# class properties must match the JSON keys to correctly convert JSON data to objects and vice versa. If they don't match, data may be lost or cause errors during serialization or deserialization.Click to reveal answer
Which method reads the entire content of a JSON file as a string in C#?
✗ Incorrect
File.ReadAllText reads the whole file content as a string, which can then be deserialized.
Which class is used to convert JSON strings to C# objects?
✗ Incorrect
JsonSerializer provides methods to serialize and deserialize JSON data.
What happens if the C# class property names do not match JSON keys during deserialization?
✗ Incorrect
Properties without matching JSON keys are ignored, so data may be missing.
How do you save a C# object as a JSON file?
✗ Incorrect
You serialize the object to a JSON string and then write that string to a file.
Which namespace must you include to work with JSON serialization in C#?
✗ Incorrect
System.Text.Json contains the JsonSerializer class for JSON operations.
Explain the steps to read data from a JSON file and convert it into a C# object.
Think about file reading and deserialization.
You got /3 concepts.
Describe how to save a C# object into a JSON file.
Focus on serialization and file writing.
You got /3 concepts.