Given:
{
"key": number,
"key2": "string",
"key3": null
}
it would be nice if one could refactor this into:
var key = number;
var key2 = "string";
var key3 = null;
or vice-versa. Care would need to be taken for different quoting styles (single vs. double) or JSON, that does not enclose the key into quotes at all or keeps a whitespace before the first colon, or no whitespaces before/after the colons at all. You can currently do this (JSON to VAR) with a regular-expression using the FilterPipes plugin (you will need to take care for the right \ escaping to be added, when you use this yourself and double escape the quote-characters):
['^\"]?(\S+?)['\"]?:\s*(\"[^\"]*\"|'[^']*'|\S+)\s*,
replacement:
"var \1 = \2;"
but it would be better to have this done programatically with some JS parsing in the background, which would make such a task more flexible.
Given:
it would be nice if one could refactor this into:
or vice-versa. Care would need to be taken for different quoting styles (single vs. double) or JSON, that does not enclose the key into quotes at all or keeps a whitespace before the first colon, or no whitespaces before/after the colons at all. You can currently do this (JSON to VAR) with a regular-expression using the FilterPipes plugin (you will need to take care for the right \ escaping to be added, when you use this yourself and double escape the quote-characters):
but it would be better to have this done programatically with some JS parsing in the background, which would make such a task more flexible.