Try to convert JS objects to valid JSON

This is a best effort approach using regular expressions. There may be a mature lib or better way to do this, but this will work in most cases.

Closes #2