Adding JSON quotes with Vim

I just had some bad JSON and quickly replaced the bad text with good text using my magic Vim editor:

The bad code looked like:
{
    prop: "value"
}

But JSON requires:
{
    "prop": "value"
}

Here is the command I used in Vim:

%s#\([^"\t ][a-zA-Z0-9_-]*\):\([\t ]\+\)#"\1":\2#gc

Ciao,
Juve

Comments