ListToXmlOrJson 1.0.1
dotnet add package ListToXmlOrJson --version 1.0.1
NuGet\Install-Package ListToXmlOrJson -Version 1.0.1
<PackageReference Include="ListToXmlOrJson" Version="1.0.1" />
<PackageVersion Include="ListToXmlOrJson" Version="1.0.1" />
<PackageReference Include="ListToXmlOrJson" />
paket add ListToXmlOrJson --version 1.0.1
#r "nuget: ListToXmlOrJson, 1.0.1"
#:package ListToXmlOrJson@1.0.1
#addin nuget:?package=ListToXmlOrJson&version=1.0.1
#tool nuget:?package=ListToXmlOrJson&version=1.0.1
ListToXmlOrJson ✨
A Simple & Elegant .NET Data Export Utility
Effortlessly export any List<T> to JSON or XML files with just one line of code! Built with native .NET libraries – no external dependencies.
🚀 Features
✔ One-method solution – Simple and intuitive API
✔ Supports any object type – Fully generic implementation
✔ Native .NET serialization – Uses System.Text.Json and System.Xml.Serialization
✔ Lightweight – Zero external dependencies
✔ Robust error handling – Validates inputs and throws meaningful exceptions
📦 Installation
Via NuGet Package Manager:
Install-Package ListToXmlOrJson
Or using .NET CLI:
dotnet add package ListToXmlOrJson
🛠 Usage
1️⃣ Define your model
//Example code:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
2️⃣ Prepare your data
//Example code:
var people = new List<Person>
{
new Person { Name = "John", Age = 30 },
new Person { Name = "Mary", Age = 25 }
};
3️⃣ Export to JSON or XML
//Example code:
using ListToXmlOrJson;
// Export to JSON
ExportData<Person>.SaveData("people", people, ExportData<Person>.FileFormat.Json);
// Export to XML
ExportData<Person>.SaveData("people", people, ExportData<Person>.FileFormat.Xml);
This generates:
📄 people.json
📄 people.xml
📜 API Reference
ExportData<T>.SaveData
public static void SaveData(string file, List<T> data, FileFormat fileFormat)
| Parameter | Type | Description |
|---|---|---|
file |
string |
Output filename (without extension) |
data |
List<T> |
Collection of objects to export |
fileFormat |
FileFormat |
Export format (Json or Xml) |
Exceptions:
- ⚠️ ArgumentNullException → If data is null
- ⚠️ Exception → If an unsupported format is provided
❓ Why Use This?
✔ No complex setup – Works out of the box
✔ Clean and maintainable – Single responsibility principle
✔ Production-ready – Proper error handling
✔ Lightweight – No bloat, just pure functionality
🌟 Example Output
JSON (people.json)
[
{
"Name": "John",
"Age": 30
},
{
"Name": "Mary",
"Age": 25
}
]
XML (people.xml)
<ArrayOfPerson>
<Person>
<Name>John</Name>
<Age>30</Age>
</Person>
<Person>
<Name>Mary</Name>
<Age>25</Age>
</Person>
</ArrayOfPerson>
🌐 Developed by NandoDeveloper
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 167 | 5/31/2025 |