Refactored json writer as a helper

This will create a more convenient way to send json from any of your endpoints.