fromJSONish function

Validates and fixes some JSON issues, eg removing newlines etc