move json dumping from helper functions to views