Added encoder-like JSON behaviour