Saving certain control characters in Plugin settings cause JSON parsing errors

When attempting to save a setting with a name or value that has a character in the following ranges, it creates a parsing error, causing the plugin setting to be unreadable until the next write.

Ranges (in decimal): 0-8, 11, 12, 14-31

This was done via trial and error in the control character range, so it’s possible that there’s other characters that cause errors, but these are the ones I encountered.

You can replicate this rather easily by running plugin:SetSetting("foo", "\bar") and then trying to access any setting from the same plugin.

As an example, prior to running this code, my settings.json looked like this:

After running it (notice the error):

Then when reading from it:

The expected behavior is that \v and \0 aren’t allowed in json files (they aren’t normally) and that control characters are properly escaped. The current behavior is this.