import decimal
import json


def event_json_dumps(event_data):
    """Serializes the event as JSON.

    Decimals are converted to string, not float, to prevent the loss of accuracy.
    """

    def decimal_default(obj):
        if isinstance(obj, decimal.Decimal):
            return str(obj)
        raise TypeError

    return json.dumps(event_data, default=decimal_default)