Extends the SQL Method tojson() to accept format parameter

This pull request addresses the issue #1393