LogOtter.JsonHal
3.0.0
dotnet add package LogOtter.JsonHal --version 3.0.0
NuGet\Install-Package LogOtter.JsonHal -Version 3.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="LogOtter.JsonHal" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogOtter.JsonHal" Version="3.0.0" />
<PackageReference Include="LogOtter.JsonHal" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LogOtter.JsonHal --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LogOtter.JsonHal, 3.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.
#:package LogOtter.JsonHal@3.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LogOtter.JsonHal&version=3.0.0
#tool nuget:?package=LogOtter.JsonHal&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JsonHal
A library to help build JsonHal links.
Usage
Add a links collection to your response object.
Note: Ensure you set the
[JsonPropertyName]attribute to_links
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
public class ExampleResponse
{
public required IReadOnlyCollection<string> Data { get; init; }
[JsonPropertyName("_links")]
public required JsonHalLinkCollection Links { get; init; }
[SetsRequiredMembers]
public ExampleResponse(IReadOnlyCollection<string> data)
{
Data = data;
Links = new JsonHalLinkCollection();
}
public ExampleResponse()
{
}
}
Build your response using the helper methods.
var response = new ExampleResponse(data);
response.Links.AddFirstLink("https://example.com/data?page=1");
response.Links.AddPrevLink("https://example.com/data?page=2");
response.Links.AddSelfLink("https://example.com/data?page=3");
response.Links.AddNextLink("https://example.com/data?page=4");
response.Links.AddLastLink("https://example.com/data?page=5");
For paged responses, use the helper to generate all links (first, prev, self, next, last):
response.Links.AddPagedLinks(currentPage, totalPages, p => $"https://example.com/data?page={p}");
Use ASP.NET Url helper for help crafting full URLs, e.g.
response.Links.AddSelfLink(Url.Link(
"RouteName", // replace with the name of the route
new { page = currentPage } // replace with route parameters
));
More Information
See HAL - Hypertext Application Language for the specification
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LogOtter.JsonHal:
| Package | Downloads |
|---|---|
|
LogOtter.CosmosDb.EventStore
A lightweight event sourcing abstraction for CosmosDb. |
GitHub repositories
This package is not used by any popular GitHub repositories.