'GET /api/tools/json
Get the tool form JSON for a tool in a repository.
:param guid:          the GUID of the tool
:param guid:          str
:param tsr_id:        the ID of the repository
:param tsr_id:        str
:param changeset:     the changeset at which to load the tool json
:param changeset:     str'

@expose_api_raw_anonymous_and_sessionless
def json(self, trans, **kwd):

    guid = kwd.get('guid', None)
    tsr_id = kwd.get('tsr_id', None)
    changeset = kwd.get('changeset', None)
    if (None in [changeset, tsr_id, guid]):
        message = 'Changeset,    repository    ID,    and    tool    GUID    are    all    required    parameters.'
        trans.response.status = 400
        return {'status': 'error', 'message': message}
    tsucm = ToolShedUtilityContainerManager(trans.app)
    repository = repository_util.get_repository_in_tool_shed(self.app, tsr_id)
    repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed(repository.user, repository)
    repository_metadata = metadata_util.get_repository_metadata_by_changeset_revision(trans.app, tsr_id, changeset)
    toolshed_base_url = str(web.url_for('/', qualified=True)).rstrip('/')
    rb = relation_builder.RelationBuilder(trans.app, repository, repository_metadata, toolshed_base_url)
    repository_dependencies = rb.get_repository_dependencies_for_changeset_revision()
    containers_dict = tsucm.build_repository_containers(repository, changeset, repository_dependencies, repository_metadata)
    found_tool = None
    for folder in containers_dict['valid_tools'].folders:
        if hasattr(folder, 'valid_tools'):
            for tool in folder.valid_tools:
                tool.id = tool.tool_id
                tool_guid = suc.generate_tool_guid(repository_clone_url, tool)
                if (tool_guid == guid):
                    found_tool = tool
                    break
    if (found_tool is None):
        message = ('Unable    to    find    tool    with    guid    %s    in    repository    %s.' % (guid, repository.name))
        trans.response.status = 404
        return {'status': 'error', 'message': message}
    tv = tool_validator.ToolValidator(trans.app)
    (repository, tool, message) = tv.load_tool_from_changeset_revision(tsr_id, changeset, found_tool.tool_config)
    if message:
        status = 'error'
        return dict(message=message, status=status)
    tool_help = ''
    if tool.help:
        tool_help = tool.help.render(static_path=web.url_for('/static'), host_url=web.url_for('/', qualified=True))
        tool_help = util.unicodify(tool_help, 'utf-8')
    tool_dict = tool.to_dict(trans)
    tool_dict['inputs'] = {}
    tool.populate_model(trans, tool.inputs, {}, tool_dict['inputs'])
    tool_dict.update({'help': tool_help, 'citations': bool(tool.citations), 'biostar_url': trans.app.config.biostar_url, 'requirements': [{'name': r.name, 'version': r.version} for r in tool.requirements], 'state_inputs': params_to_strings(tool.inputs, {}, trans.app), 'display': tool.display_interface, 'action': web.url_for(tool.action), 'method': tool.method, 'enctype': tool.enctype})
    return json.dumps(tool_dict)
