Fix config writing illegal Json strings

Input string values for config settings are used without being checked (unlike int and bool values), which means that illegal Json values like unescaped backslashes will be saved in the config.json and break future config usage.

For example, calling ```config -g cache-files-dir C:\Users\Name\ComposerCache``` produces the following entry:

```
"cache-files-dir": "C:\Users\Name\ComposerCache"
```
This PR fixes the issue by parsing the string first. I am not sure if I have put this in the correct place, so feel free to amend, delete or whatever.