Improve json import

The stream parser now covers the cases of parsing failure (invalid JSON).