import json
import numpy as np

TIMESTAMP_10 = r"^\d{10}(\.\d+)?$"
TIMESTAMP_13 = r"^\d{13}$"


class NpEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.integer):
            return int(obj)
        if isinstance(obj, np.floating):
            return float(obj)
        if isinstance(obj, np.ndarray):
            return obj.tolist()
        return json.JSONEncoder.default(self, obj)
