Feature: toJSON()-function

Added a function for converting a model to the JSON-format and also
fixed a problem with tables without any index.