package com.ss.android.ugc.effectmanager.knadapt;

import X.7y5;
import X.9lJ;
import X.C2828Q5p;
import X.M12;
import X.Q39;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.effectmanager.common.listener.IJsonConverter;
import java.io.ByteArrayInputStream;
import kotlin.h.b.n;

public final class KNJsonConverter implements C2828Q5p {
    public final IJsonConverter jsonConverter;

    static {
        Covode.recordClassIndex(125533);
    }

    public final <T> String convertObjToJson(T t) {
        return this.jsonConverter.convertObjToJson(t);
    }

    public KNJsonConverter(IJsonConverter iJsonConverter) {
        M12.LIZ(iJsonConverter);
        this.jsonConverter = iJsonConverter;
    }

    public final <T> T convertJsonToObj(String str, Class<T> cls) {
        MethodCollector.i(11360);
        M12.LIZ(str, cls);
        byte[] bytes = str.getBytes(9lJ.LIZ);
        n.LIZ(bytes, Q39.LIZJ);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        try {
            IJsonConverter iJsonConverter = this.jsonConverter;
            byte[] bytes2 = str.getBytes(9lJ.LIZ);
            n.LIZ(bytes2, Q39.LIZJ);
            T convertJsonToObj = iJsonConverter.convertJsonToObj(new ByteArrayInputStream(bytes2), cls);
            7y5.LIZ(byteArrayInputStream, (Throwable) null);
            MethodCollector.o(11360);
            return convertJsonToObj;
        } catch (Throwable th) {
            7y5.LIZ(byteArrayInputStream, th);
            MethodCollector.o(11360);
            throw th;
        }
    }
}
