Fix JSON string re-encoding to support escapes