import json
import click


def json_to_dict(ctx, param, value):
    """Convert JSON to dictionary"""
    if value is None:
        return {}
    try:
        return json.loads(value)
    except ValueError:
        raise click.BadParameter('Invalid JSON for {0}: {1}'.format(param, value))