Serialize api responses to JSON