EN: A C# .NET console application demonstrating advanced JSON deserialization techniques. This project focuses on handling "nested JSON" where a property contains a stringified JSON object that requires a second layer of parsing.
DE: Eine C# .NET Konsolenanwendung, die fortgeschrittene Techniken zur JSON-Deserialisierung demonstriert. Dieses Projekt konzentriert sich auf den Umgang mit "verschachteltem JSON", bei dem eine Eigenschaft ein stringifiziertes JSON-Objekt enthält, das eine zweite Ebene des Parsings erfordert.
- Two-Step Deserialization: Extracts a nested JSON string from a parent object (
Product.Data) into a concrete class (Data). - Data Transformation: Uses Extension Methods to map separate arrays (Color, Price, OfferPrice) into a structured
Dictionary. - LINQ Integration: Dynamically calculates the
MinPriceusing LINQ logic within the data model. - Robust Framework: Built on .NET Framework 4.6.1 using the
Newtonsoft.Jsonlibrary.
| File / Datei | Role / Rolle |
|---|---|
Product.cs |
The main wrapper model containing the raw JSON string. |
Data.cs |
The internal model for product details like colors and prices. |
DataHelper.cs |
Contains extension methods to process and sync raw data. |
Program.cs |
Entry point that executes the parsing and displays results. |
- Visual Studio 2017+.
- .NET Framework 4.6.1.
- Newtonsoft.Json NuGet Package (v13.0.3).
- Clone the repository / Repository klonen.
- Open
JasonSerializedDeserialized.slnin Visual Studio. - Restore NuGet packages / NuGet-Pakete wiederherstellen.
- Run the project (F5) / Projekt ausführen (F5).
EN: The application takes a complex JSON string and outputs:
- The minimum price calculated from the nested data.
- A mapped list of prices and offer prices organized by color.
DE: Die Anwendung nimmt einen komplexen JSON-String entgegen und gibt Folgendes aus:
- Den aus den verschachtelten Daten berechneten Mindestpreis.
- Eine nach Farben geordnete Liste von Preisen und Angebotspreisen.
EN: The project utilizes [JsonIgnore] on calculated properties to prevent circular references and keep the serialization clean.
DE: Das Projekt verwendet [JsonIgnore] für berechnete Eigenschaften, um Zirkelbezüge zu verhindern und die Serialisierung sauber zu halten.
This project is open-source and available under the MIT License.