JsonTemplates 1.0.0
dotnet add package JsonTemplates --version 1.0.0
NuGet\Install-Package JsonTemplates -Version 1.0.0
<PackageReference Include="JsonTemplates" Version="1.0.0" />
<PackageVersion Include="JsonTemplates" Version="1.0.0" />
<PackageReference Include="JsonTemplates" />
paket add JsonTemplates --version 1.0.0
#r "nuget: JsonTemplates, 1.0.0"
#:package JsonTemplates@1.0.0
#addin nuget:?package=JsonTemplates&version=1.0.0
#tool nuget:?package=JsonTemplates&version=1.0.0
What are JSON Templates?
Json tempaltes are a way to help move boilerplate json into a reusable file. No more duplicated json in variations of config files. Intead push all the basics down a level and just deal with the differences. Its easy!
How?
Similarly to the $schema directives, we can use a $template directive. This uses a relative file path, to find the template. The template is loaded in first, and then the current json is applied in a layer above.
Example
Lets first look at a simple user object with a template
{
"$template": "..\\templates\\user.json"
"id": 12402945,
"email": "some.mail@a.place",
"isVerified": true,
"profile": {
"language": "fr-fr"
}
}
And then the user template would look like. This template references another template. That template only applies to the scope of profile.
{
"isVerified": false,
"isActive": true,
"profile": {
"$template": "profile.json",
}
}
And then the profile template
{
"language": "en-us",
"timezone": "UTC+0",
}
Together they merge nicely into a single document when we load the base. Notice the $template properties are dropped. Also values from the templates are replaced by the higher level.
{
"id": 12402945,
"email": "some.mail@a.place",
"isVerified": true,
"isActive": true,
"profile": {
"language": "fr-fr"
"timezone": "UTC+0",
}
}
Quick Start
To load a templated json, simply pass the file path into the library like so
using System.Text.Json.Nodes;
using JsonTemplates;
string filePath = "path to your json";
JsonNode? json = JsonTemplate.LoadJson(filePath);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net10.0 was computed. 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. |
-
net8.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 | 185 | 6/20/2025 |