Update to value rendering using json_encode

Fixed rendering that caused JSON object to break added json_encode function to solve issue, also variable names where given a '$' prefix to use native php to render templates.