Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kirill22012002/jsonasdatastorage

JSON as Data Storage. For example caching data to json. Or for simple project use json as Data Storage
https://github.com/kirill22012002/jsonasdatastorage

c-sharp dotnet json newtonsoft-json

Last synced: 1 day ago
JSON representation

JSON as Data Storage. For example caching data to json. Or for simple project use json as Data Storage

Awesome Lists containing this project

README

        

# JsonAsDataStorage

```csharp
public class User
{
public string UserId { get; set; }
public string UserName { get; set; }
}

// init
IBaseStorage userStorage = new BaseStorage(filePath: "users.json", idField: "UserId");

var user = new User
{
UserId = Guid.NewGuid().ToString(),
UserName = "Kirill"
};

// insert new data
await userStorage.InsertItemAsync(user);

// get by id
var result = await userStorage.GetItemAsync(user.UserId);

// update by id
await userStorage.UpdateItemAsync(user.UserId, new User { UserId = user.UserId, UserName = "Alexey" });

// delete by id
await userStorage.DeleteItemAsync(user.UserId);

```