package com.bytedance.sdk.component.fm;

import java.lang.reflect.Type;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
class wsy {
    private vt fm;

    private wsy(vt vtVar) {
        this.fm = vtVar;
    }

    public static wsy fm(vt vtVar) {
        return new wsy(vtVar);
    }

    public <T> T fm(String str, Type type) throws JSONException {
        fm(str);
        return (type.equals(JSONObject.class) || ((type instanceof Class) && JSONObject.class.isAssignableFrom((Class) type))) ? (T) new JSONObject(str) : (T) this.fm.fm(str, type);
    }

    public <T> String fm(T t10) {
        String string;
        if (t10 == null) {
            return "{}";
        }
        if (!(t10 instanceof JSONObject) && !(t10 instanceof JSONArray)) {
            string = this.fm.fm(t10);
        } else {
            string = t10.toString();
        }
        fm(string);
        return string;
    }

    private static void fm(String str) {
        if (str.startsWith("{") && str.endsWith("}")) {
            return;
        }
        wu.fm(new IllegalArgumentException("Param is not allowed to be List or JSONArray, rawString:\n ".concat(str)));
    }
}
