Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/am1goo/system.text.json.combiner
Easiest way to inline one JSON file to another one
https://github.com/am1goo/system.text.json.combiner
csharp deserialization dotnet inline json serialization system text
Last synced: 25 days ago
JSON representation
Easiest way to inline one JSON file to another one
- Host: GitHub
- URL: https://github.com/am1goo/system.text.json.combiner
- Owner: am1goo
- License: mit
- Created: 2024-03-09T13:57:04.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-21T11:26:13.000Z (9 months ago)
- Last Synced: 2024-12-13T05:26:49.795Z (27 days ago)
- Topics: csharp, deserialization, dotnet, inline, json, serialization, system, text
- Language: C#
- Homepage:
- Size: 109 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/am1goo/System.Text.Json.Combiner)
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues-pr/am1goo/System.Text.Json.Combiner)
![GitHub License](https://img.shields.io/github/license/am1goo/System.Text.Json.Combiner)# System.Text.Json.Combiner
#### What is this:
You can deserialize a lot of inlined `JSON` files in one `JSON` file from different sources (local or remote files), like that:#### Supported schemes:
- `file://` to load file from system
- `http://` and `https://` to load files from web servers#### How it can be used:
Use `JsonCombiner` instead of `JsonSerializer` to deserialize JSON file from file system and inherit each inlined class or struct from `IJsonCombine` interface
```csharp
public TestObject LoadFromFile(string relativePath)
{
string path = Path.Combine(Environment.CurrentDirectory, relativePath);
return JsonCombiner.Deserialize(path, options);
}
```Also you can able to make your own json `IJsonLoader` variant and register it via `JsonCombiner.RegisterLoader` method.
```csharp
private void Main(string[] args)
{
var myLoader = new MyJsonLoader();
JsonCombiner.RegisterLoader("myhttp", myLoader);
}
```#### Example:
*Root file:*
```json
{
"param1": "param1",
"param2": 2,
"param3": 3.3,
"inner1": "file://inline/inner_object_1.json",
"inner2": "inline/inner_object_2.json",
"inner3": "http://any.public.host.xyz/json.file.json"
}
```*File `inline/inner_object_1.json`:*
```json
{
"arg1": "arg1",
"arg2": 44,
"arg3": 55.55
}
```*File `inline/inner_object_2.json`:*
```json
{
"arg1": "arg2",
"arg2": 66,
"arg3": 77.77
}
```