i need a valid JSON format to request ES. i have a string like
{ time: { from:now-60d, mode:quick, to:now } }
maybe you can use :
str.replace(/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)/g, "\"$1\":\"$2\"");
Here is regex demo
Note
In the group [a-zA-Z0-9-] of characters i use alphabetical digits and a -, maybe you need other so you can use another one
[a-zA-Z0-9-]
alphabetical
digits
-