Skip to content

sleeuwen/dotnet-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotnet-json

nuget

dotnet-json is a command line tool for working with and manipulating JSON files for example in CI/CD pipelines.

dotnet-json allows you to do basic manipulation of JSON files like setting the value of a specific (nested) key, or deleting a key, as well as merging two or more JSON files into one.

Installation

dotnet-json can be installed as a .NET Core (global) tool or be downloaded directly from the GitHub releases.

To install dotnet-json as a global tool, run the following command:

dotnet tool install -g dotnet-json

Or, if you already have dotnet-json installed and want to update it to the latest version, run the following command:

dotnet tool update -g dotnet-json

Usage

When you installed dotnet-json as a .NET Core global tool, you can run it as either dotnet json or dotnet-json.

dotnet-json has 5 sub-commands, merge, set, remove, get and indent.

Merge

Merges two or more files into the first, writing it back to the first file or into a specified output file.

Usage:

dotnet json merge <input file> <merge files...> [-o|--output <output file>]

Arguments:

  • <input file> The first JSON file used as base to merge the other files' contents into, also used as default output
  • <merge files...> One or more JSON files that are merged into the first file

Options:

  • -o|--output file Write the merge result to a custom output file instead of using the input file

Set

Set a specific value in the JSON file. Use : as separator for nesting objects.

Usage:

dotnet json set <file> <key> <value> [-o|--output <output file>]

Arguments:

  • <file> The file to read the JSON from and write the result to unless -o is given.
  • <key> The key to update or create, use : to separate nested objects.
  • <value> The value to set the key to

Options:

  • -o|--output file Write the result to a custom output file instead of using the input file
  • -e|--existing Only set the value if the key already exists in the json file, otherwise do nothing

remove

Removes a key/value pair or complex object from a JSON file.

Usage:

dotnet json remove <file> <key> [-o|--output <output file>]

Arguments:

  • <file> The file to read the JSON from and write the result to unless -o is given.
  • <key> The key to remove from the read JSON

Options:

  • -o|--output file Write the result to a custom output file instead of using the input file

get

Reads the json file and returns the value for the given key.

Usage:

dotnet json get <file> <key> [-e|--exact]

Arguments:

  • <file> The file to read the JSON from.
  • <key> The key to output

Options:

  • -e|--exact only return an exact value, this will return an error if the key references an object or array.

indent

Reads the json file and writes it out with indentation.

Usage:

dotnet json indent <file> [-o|--output <output file>]

Arguments:

  • <file> The file to read the JSON from and write the result to unless -o is given.

Options:

  • -o|--output file Write the result to a custom output file instead of writing back to the input file

About

.NET Global Tool for manipulation .json files

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages