Added json api

Resolves #6