So I have a string:
{"age":{"type":"Number","max":100,"default":"() => 0"},"created_at":{"type":"String","default":"() => moment().format("YY/MM/DD")"}
I need to remove the outer double quotes from the values where the key is default
. So the above string would become:
{"age":{"type":"Number","max":100,"default":() => 0},"created_at":{"type":"String","default":() => moment().format("YY/MM/DD")}
I am using sed
to do this right now, and this is the latest command I’ve tried:
sed -r 's/"(default)":"([^"]*)"/\1: \2/g'
The problem occurs at "() => moment().format("YY/MM/DD")"
, the regex matches until the first "
.
I’d really appreciate a regex that can solve this problem. It doesn’t have to be done in a single step, I can run multiple commands in succession as long as I can successfully remove the outer double quotes.
It also doesn’t have to be a sed
command, it can be done through file manipulation as well, as long as the code is valid in javascript