Cake.Json

A set of aliases to help with JSON Serialization

#addin nuget:?package=Cake.Json&version=5.2.0

<package id="Cake.Json" version="5.2.0" />

dotnet add package Cake.Json --version 5.2.0

<PackageReference Include="Cake.Json" Version="5.2.0" />

Aliases

JSON related cake aliases.

In order to use aliases from this addin, you will need to also reference Newtonsoft.Json as an addin. Here is what including Cake.Json in your script should look like:

#addin package:?Cake.Json
#addin package:?Newtonsoft.Json&version=11.0.2

General

DeserializeJson<T>(ICakeContext, string) Deserializes the JSON from a string.
DeserializeJsonFromFile<T>(ICakeContext, FilePath) Deserializes the JSON from a file.
ParseJson(ICakeContext, string) Parses the JSON into a JObject.
ParseJsonFromFile(ICakeContext, FilePath) Parses the file contents into a JObject.
SerializeJson<T>(ICakeContext, T) Serializes an object to a JSON string.
SerializeJsonPretty<T>(ICakeContext, T) Serializes an object to a pretty JSON string.
SerializeJsonToFile<T>(ICakeContext, FilePath, T) Serializes an object to a JSON file.
SerializeJsonToPrettyFile<T>(ICakeContext, FilePath, T) Serializes an object to a pretty JSON file.