-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from DevyusCode/doc
Updated documentation
- Loading branch information
Showing
203 changed files
with
1,619 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
Documentation/.vitepress/cache/deps/vitepress___@vue_devtools-api.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Documentation/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# JsonHelper | ||
|
||
This page is about the `JsonHelper` class available in PeyrSharp.Core. | ||
You can find here all of its methods. | ||
|
||
::: info | ||
This class is `static`. | ||
::: | ||
|
||
## Compatibility | ||
|
||
The `JsonHelper` class is part of the `PeyrSharp.Core` module, which is compatible with all of these frameworks and platforms: | ||
|
||
| Package/Platform | Windows | macOS | Linux + others | | ||
| ---------------- | ---------- | ---------- | -------------- | | ||
| Core | ✅ | ✅ | ✅ | | ||
| **Framework** | **.NET 5** | **.NET 6** | **.NET 7** | | ||
| Core | ✅ | ✅ | ✅ | | ||
|
||
## Methods | ||
|
||
### LoadFromJson\<T>(fileName) | ||
|
||
#### Definition | ||
|
||
The `LoadFromJson<T>()` method loads an object from a JSON file. | ||
|
||
#### Type Parameters | ||
|
||
| Type | Meaning | | ||
| ---- | ------------------------------- | | ||
| `T` | The type of the object to save. | | ||
|
||
#### Arguments | ||
|
||
| Type | Name | Meaning | | ||
| -------- | ---------- | ---------------------------------- | | ||
| `string` | `fileName` | The name of the file to load from. | | ||
|
||
#### Returns | ||
|
||
The object loaded from the file. | ||
|
||
#### Usage | ||
|
||
```c# | ||
using PeyrSharp.Core; | ||
using System.IO; | ||
using System.Text.Json; | ||
|
||
// Load the person from the JSON file | ||
Person person = JsonHelper.LoadFromJson<Person>("person.json"); | ||
|
||
// Print the person's name and age | ||
Console.WriteLine($"Name: {person.Name}, Age: {person.Age}"); | ||
``` | ||
|
||
### SaveAsJson\<T>(obj, fileName) | ||
|
||
#### Definition | ||
|
||
The `SaveAsJson()` method saves an object as a JSON file. | ||
|
||
#### Type Parameters | ||
|
||
| Type | Meaning | | ||
| ---- | ------------------------------- | | ||
| `T` | The type of the object to save. | | ||
|
||
#### Arguments | ||
|
||
| Type | Name | Meaning | | ||
| -------- | ---------- | -------------------------------- | | ||
| `T` | `obj` | The object to save. | | ||
| `string` | `fileName` | The name of the file to save to. | | ||
|
||
#### Usage | ||
|
||
```c# | ||
using PeyrSharp.Core; | ||
using System.IO; | ||
using System.Text.Json; | ||
|
||
public static void Main() | ||
{ | ||
// Create an object to save | ||
MyObject obj = new MyObject(); | ||
|
||
// Save the object as a JSON file | ||
JsonHelper.SaveAsJson(obj, "output.json"); | ||
} | ||
|
||
public class MyObject | ||
{ | ||
public string Name { get; set; } | ||
public int Age { get; set; } | ||
} | ||
``` |
Oops, something went wrong.