add JSON encoder

mainly for doing AJAX. Use "jansson" JSON library.