JsonFileWrapper 1.0.4

dotnet add package JsonFileWrapper --version 1.0.4
NuGet\Install-Package JsonFileWrapper -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JsonFileWrapper" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsonFileWrapper --version 1.0.4
#r "nuget: JsonFileWrapper, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JsonFileWrapper as a Cake Addin
#addin nuget:?package=JsonFileWrapper&version=1.0.4

// Install JsonFileWrapper as a Cake Tool
#tool nuget:?package=JsonFileWrapper&version=1.0.4

JsonFileWrapper

This is another file I created to explain generic classes for my students. So I created this generic class that loads and saves json objects. All you need to do is to give it the object to use and the filename. Then you can load and save the object while you work on it.

This project is losely based on the Bridge design pattern.

Installation

Use the package manager in Visual Studio to install JsonFileWrapper or use the package-manager window.

install-package JsonFileWrapper

Usage

// Example object
class Person
{
    public string Name { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
}
using MarcusMedinaPro.JsonFileWrapper;
// preparing the object
var file = new JsonFile<List<Person>>("Cool Actors")
{
    Data = new List<Person>(),
};
file.Load();
var Actors = file.Data;

// Now you can use your list as you want
Actors.Add(new Person { Name = "Adam", LastName = "West" });
Actors.Add(new Person { Name = "Bob", LastName = "Hoskins" });
Actors.Add(new Person { Name = "James", LastName = "Woods" });

// Save the sorted list
file.Data = Actors.OrderBy(x => x.LastName).ToList();
file.Save();

Result

[
  {
    "LastName": "Hoskins",
    "Name": "Bob"
  },
  {
    "LastName": "West",
    "Name": "Adam"
  },
  {
    "LastName": "Woods",
    "Name": "James"
  }
]

Nothing fancy but it saves you the time of writing the serialization and deserialization code.

======= var People = file.Data;

// Now you can use your list as you want People.Add(new Person { Name = "Adam", LastName = "West" }); People.Add(new Person { Name = "Bob", LastName = "Hoskins" }); People.Add(new Person { Name = "James", LastName = "Woods" });

// Save the list file.Save();

## Source code
You can find the code on my [Github](https://github.com/MarcusMedinaPro/JsonFileWrapper) account.

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[Apache 2](https://tldrlegal.com/license/apache-license-2.0-%28apache-2.0%29)

## Thanks list
[Json file Icon](https://iconscout.com/icons/json-file) by [First Styles](https://iconscout.com/contributors/first-styles) on [Iconscout](https://iconscout.com)
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.4 898 1/21/2022
1.0.3 822 1/21/2022
1.0.2 811 1/14/2022
1.0.1 826 1/14/2022
1.0.0.1 922 1/13/2022