# Path: fastavro/__main__.py
# class CleanJSONEncoder(json.JSONEncoder):
#     def default(self, obj):
#         if isinstance(obj, (datetime.date, datetime.datetime)):
#             return obj.isoformat()
#         elif isinstance(obj, (Decimal, UUID)):
#             return str(obj)
#         elif isinstance(obj, bytes):
#             return obj.decode("iso-8859-1")
#         else:
#             return json.JSONEncoder.default(self, obj)
# 
# Path: tests/conftest.py
# def assert_naive_datetime_equal_to_tz_datetime(naive_datetime, tz_datetime):
#     # mktime appears to ignore microseconds, so do this manually
#     microseconds = int(time.mktime(naive_datetime.timetuple())) * 1000 * 1000
#     microseconds += naive_datetime.microsecond
#     aware_datetime = datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(
#         microseconds=microseconds
#     )
#     assert aware_datetime == tz_datetime


import fastavro
import json
import pytest
import datetime
import sys
import os
import numpy as np
    import pandas as pd
from fastavro.__main__ import CleanJSONEncoder
from decimal import Decimal
from io import BytesIO
from uuid import uuid4
from datetime import timezone, timedelta
from .conftest import assert_naive_datetime_equal_to_tz_datetime
        datetime.date.today(),
        uuid4(),
        Decimal("1.23"),
        bytes(b"\x00\x01\x61\xff"),
    ]
    str_values = [
        values[0].isoformat(),
        values[1].isoformat(),
        str(values[2]),
        str(values[3]),
        values[4].decode("iso-8859-1"),
    ]
    assert json.dumps(values, cls=CleanJSONEncoder) == json.dumps(str_values)


def test_clean_json_dict():
    values = {
        "1": datetime.datetime.now(),
        "2": datetime.date.today(),
        "3": uuid4(),
        "4": Decimal("1.23"),
        "5": bytes(b"\x00\x01\x61\xff"),
    }
    str_values = {
        "1": values["1"].isoformat(),
        "2": values["2"].isoformat(),
        "3": str(values["3"]),
        "4": str(values["4"]),
        "5": values["5"].decode("iso-8859-1"),
    }

# Path: fastavro/__main__.py
# class CleanJSONEncoder(json.JSONEncoder):
#     def default(self, obj):
#         if isinstance(obj, (datetime.date, datetime.datetime)):
#             return obj.isoformat()
#         elif isinstance(obj, (Decimal, UUID)):
#             return str(obj)
#         elif isinstance(obj, bytes):
#             return obj.decode("iso-8859-1")
#         else:
#             return json.JSONEncoder.default(self, obj)
# 
# Path: tests/conftest.py
# def assert_naive_datetime_equal_to_tz_datetime(naive_datetime, tz_datetime):
#     # mktime appears to ignore microseconds, so do this manually
#     microseconds = int(time.mktime(naive_datetime.timetuple())) * 1000 * 1000
#     microseconds += naive_datetime.microsecond
#     aware_datetime = datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(
#         microseconds=microseconds
#     )
#     assert aware_datetime == tz_datetime


# Path: tests/test_logical_types.py
import fastavro
import json
import pytest
import datetime
import sys
import os
import numpy as np
    import pandas as pd
from fastavro.__main__ import CleanJSONEncoder
from decimal import Decimal
from io import BytesIO
from uuid import uuid4
from datetime import timezone, timedelta
from .conftest import assert_naive_datetime_equal_to_tz_datetime

        datetime.date.today(),
        uuid4(),
        Decimal("1.23"),
        bytes(b"\x00\x01\x61\xff"),
    ]
    str_values = [
        values[0].isoformat(),
        values[1].isoformat(),
        str(values[2]),
        str(values[3]),
        values[4].decode("iso-8859-1"),
    ]
    assert json.dumps(values, cls=CleanJSONEncoder) == json.dumps(str_values)


def test_clean_json_dict():
    values = {
        "1": datetime.datetime.now(),
        "2": datetime.date.today(),
        "3": uuid4(),
        "4": Decimal("1.23"),
        "5": bytes(b"\x00\x01\x61\xff"),
    }
    str_values = {
        "1": values["1"].isoformat(),
        "2": values["2"].isoformat(),
        "3": str(values["3"]),
        "4": str(values["4"]),
        "5": values["5"].decode("iso-8859-1"),
    }

    assert json.dumps(values, cls=CleanJSONEncoder) == json.dumps(str_values)