Fixes #3869 Construct json data using view system rather than global variable. Also Fixes #5062, #5061

To Do:
 * Handle exceptions - http://trac.elgg.org/ticket/5062#ticket - done!
 * Provide json for user and group profile pages - http://trac.elgg.org/ticket/5061#ticket - done!
 * Separate the json views from the export system
 * Provide a way for plugins to extend/change what is available in the json data (maybe $object->getPublicCopy() which triggers a plugin hook)