as_json for chats and messages