def import_template_json(template_json_string,allow_update=True, **kwargs):
    """
        Add the template, type and typeattrs described
        in a JSON file.

        Delete type, typeattr entries in the DB that are not in the XML file
        The assumption is that they have been deleted and are no longer required.

        The allow_update indicates whether an existing template of the same name should
        be updated, or whether it should throw an 'existing name' error.
    """

    user_id = kwargs.get('user_id')

    try:
        template_dict = json.loads(template_json_string)
    except:
        raise HydraError("Unable to parse JSON string. Plese ensure it is JSON compatible.")

    return import_template_dict(template_dict, allow_update=allow_update, user_id=user_id)
Add the template, type and typeattrs described
        in a JSON file.

        Delete type, typeattr entries in the DB that are not in the XML file
        The assumption is that they have been deleted and are no longer required.

        The allow_update indicates whether an existing template of the same name should
        be updated, or whether it should throw an 'existing name' error.