Code Monkey home page Code Monkey logo

dotnet-json's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.