Code Monkey home page Code Monkey logo

json-config-transform's Introduction

json-config-transform

json-config-transform provides command for json file transformations.

The tool provides these features :

  • Applying JsonPatch transformation to a json file.

Installation

The tool is available on Nuget.

You can install the tool by executing this command :

$ dotnet tool install json-config-transform --global

Help

Use this command to list all available commands.

$ json-config-transform --help

Usages

Choose a json file to transform :

// myfile.json

{
  "name": "test",
  "description": "description",
  "properties": {
    "annotations": [],
    "runtimeState": "Started",
    "pipelines": [
      {
        "pipelineReference": {
          "referenceName": "reference",
          "type": "PipelineReference"
        },
        "parameters": {
          "parameter1": "value1",
          "parameter2": "value2"
        }
      }
    ]
  }
}

Create a configuration file which stores all transformations (list of JSON Patch operations) like this : operation : path => value

# myfile.json.config

add : /properties/pipelines/0/parameters/parameter3 => { "p1": "value1", "p2": "value2"}
replace : /properties/pipelines/0/parameters/parameter2 => value2updated
remove : /description =>

Execute the tool with the following parameters :

$ json-config-transform --source myfile.json --config myfile.json.config --display-result

After the execution, the json file should be like this :

  • description property has been removed
  • new parameter3 has been added
  • parameter2 value has been updated
// myfile.json

{
	"name": "test",
	"properties": {
		"annotations": [],
		"runtimeState": "Started",
		"pipelines": [
			{
				"pipelineReference": {
					"referenceName": "reference",
					"type": "PipelineReference"
				},
				"parameters": {
					"parameter1": "value1",
					"parameter2": "value2updated",
					"parameter3": {
						"p1": "value1",
						"p2": "value2"
					}
				}
			}
		]
	}
}

The display-result option allows to display the result of the transformation directly in the command window :

    _                                        __ _             _                        __
   (_)___  ___  _ __         ___ ___  _ __  / _(_) __ _      | |_ _ __ __ _ _ __  ___ / _| ___  _ __ _ __ ___
   | / __|/ _ \| '_ \ _____ / __/ _ \| '_ \| |_| |/ _` |_____| __| '__/ _` | '_ \/ __| |_ / _ \| '__| '_ ` _ \
   | \__ \ (_) | | | |_____| (_| (_) | | | |  _| | (_| |_____| |_| | | (_| | | | \__ \  _| (_) | |  | | | | | |
  _/ |___/\___/|_| |_|      \___\___/|_| |_|_| |_|\__, |      \__|_|  \__,_|_| |_|___/_|  \___/|_|  |_| |_| |_|
 |__/                                             |___/

Parameters :
  - Source File Path : d:\temp\NETFLIX_CATALOG_DAILY_TRIGGER.json
  - Config File Path : d:\temp\NETFLIX_CATALOG_DAILY_TRIGGER.json.config
Result :

{
  "name": "test",
  "properties": {
    "annotations": [],
    "runtimeState": "Started",
    "pipelines": [
      {
        "pipelineReference": {
          "referenceName": "reference",
          "type": "PipelineReference"
        },
        "parameters": {
          "parameter1": "value1",
          "parameter2": "value2updated",
          "parameter3": {
            "p1": "value1",
            "p2": "value2"
          }
        }
      }
    ]
  }
}

json-config-transform's People

Contributors

davidremond avatar

Watchers

 avatar

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.