add _toJson function in utils/__init__.py

PR for http://trac.buildbot.net/ticket/2659