Add value to JSON Object
Apache 2.0Adds a value at the specified keyPath with the specified key, if the key doesn't already exist.
org. openrewrite. json. AddKeyValueRequired
A JsonPath expression to locate the parent JSON object, either the object itself or the key holding it. A trailing .* is ignored, so $.x.y.* is the same as $.x.y.
The key to create, as the text it stands for. It is written with the escapes JSON needs, so \. is written \\..
The value to add to the document at the specified key. Can be of any type representing JSON value. String values should be quoted to be inserted as Strings.
Optional
prependBoolean
If set to true the value will be added to the beginning of the object
mod run . --recipe= org. openrewrite. json. AddKeyValue \
-P keyPath= ''\''$. subjects'\'' or '\''$'\'' or '\''$. x[1]. y'\'' etc. ' \
-P key= myKey \
-P value= '`"myValue"` or `{"a": 1}` or `[ 123 ]`'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.