Jsonable 1.0.0-alpha2
This is a prerelease version of Jsonable.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Jsonable --version 1.0.0-alpha2
NuGet\Install-Package Jsonable -Version 1.0.0-alpha2
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-alpha2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jsonable --version 1.0.0-alpha2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jsonable, 1.0.0-alpha2"
#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-alpha2&prerelease // Install Jsonable as a Cake Tool #tool nuget:?package=Jsonable&version=1.0.0-alpha2&prerelease
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 = ...
var message = await new HttpClient().PostAsJsonAsync("https://api.xxx.xxx/v1/xxx", (object)req);
dynamic res = JsonDocument.Parse(await message.Content.ReadAsStringAsync()).ToDynamic();
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 res = await Http.GetAsync("sample-data/weather.json");
forecasts = JsonDocument.Parse(await res.Content.ReadAsStringAsync()).ToDynamic()!;
}
}
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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 | 440 | 10/16/2022 |
1.0.0-alpha4 | 184 | 10/13/2022 |
1.0.0-alpha3 | 174 | 10/12/2022 |
1.0.0-alpha2 | 175 | 10/11/2022 |
1.0.0-alpha | 157 | 10/10/2022 |