Jsonable 1.0.0
dotnet add package Jsonable --version 1.0.0
NuGet\Install-Package Jsonable -Version 1.0.0
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="Jsonable" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jsonable --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jsonable, 1.0.0"
#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 Jsonable as a Cake Addin #addin nuget:?package=Jsonable&version=1.0.0 // Install Jsonable as a Cake Tool #tool nuget:?package=Jsonable&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jsonable
Dynamic json operations.
Usage
Convert from JsonDocument or JsonElement to dynamic.
using System.Text.Json;
// ToDynamic
dynamic json = JsonDocument.Parse("json").ToDynamic()!
Using DynamicJsonObject
using System.Text.Json;
// Create
dynamic json = Jsonable.CreateObject(x =>
{
x.user.name = "name";
x.user.age = 0;
});
// Add member
json.address = "address"; // or
json["address"] = "address";
// Delete member
json.Remove("address");
json.Clear();
// Chaining Member access
json.user.address = ""; // or
json["user"]["address"] = "";
JsonSerializer.Serialize(json) ...
Example
Web API POST
dynamic req = Jsonable.CreateObject(...
var message = await new HttpClient().PostAsJsonAsync("https://api.xxx.xxx/xxx", (object)req);
dynamic res = message.Content.ReadFromJsonToDynamicAsync();
Blazor WebAssembly 'Weather forecast'
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.date</td>
<td>@forecast.temperatureC</td>
<td>@(32 + (int)(forecast.temperatureC / 0.5556))</td>
<td>@forecast.summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private dynamic? forecasts;
protected override async Task OnInitializedAsync()
{
var message = await Http.GetAsync("sample-data/weather.json");
forecasts = await message.Content.ReadFromJsonToDynamicAsync();
}
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
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.0 | 426 | 10/16/2022 |
1.0.0-alpha4 | 180 | 10/13/2022 |
1.0.0-alpha3 | 170 | 10/12/2022 |
1.0.0-alpha2 | 171 | 10/11/2022 |
1.0.0-alpha | 153 | 10/10/2022 |