I have a large JSON file where I want to find and replace all properies with the same string
How the JSON currently looks
{
"example1": "some text1"
"example2": "some text2"
"example3": "some text3"
}
Ideal output for the JSON
{
"example1": "hello"
"example2": "hello"
"example3": "hello"
}
3
Answers
ChatGPT helped me!
regular expression in VSCODE is
(?<=":)s*".*?"
To replace all values in your JSON file with the string "hello", you can use a simple script in JavaScript.
This is a simple task for
jq
. The followingjq
script produces the expected output:See it online.
Install
jq
, then run this command in a terminal:… to process the JSON stored in the file
input.json
and save the output in the fileoutput.json
.The output will be formatted on multiple lines (and you can open
output.json
and inspect it in VSCode or another editor). If you need the output on a single line (to save space), add option-c
to thejq
command line: