import json
from typing import Any, Dict, Union

def json_constraint(constraint_type : str, constraint_value : Union[str, Dict[str, Any]]):
    if not isinstance(constraint_value, str): constraint_value = json.dumps(constraint_value, sort_keys=True)
    return {'constraint_type': constraint_type, 'constraint_value': constraint_value}
