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" />
                    
Directory.Packages.props
<PackageReference Include="LogOtter.JsonHal" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=LogOtter.JsonHal&version=3.0.0
                    
Install as a Cake Tool

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 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.

Version Downloads Last Updated
3.0.0 3,049 4/16/2026
2.0.4 2,020 11/4/2025
2.0.2 286 8/4/2025
2.0.1 3,486 4/16/2025
2.0.0 352 4/10/2025
2.0.0-alpha1 228 3/20/2025
1.2.0 1,152 1/16/2025
1.1.2 1,201 11/18/2024
1.0.1 2,606 3/8/2024
1.0.0 733 11/30/2023
Loading failed