// 
// Decompiled by Procyon v0.6.0
// 

package com.nimbusds.jose.util;

import com.nimbusds.jose.shaded.gson.ToNumberStrategy;
import com.nimbusds.jose.shaded.gson.ToNumberPolicy;
import com.nimbusds.jose.shaded.gson.Strictness;
import com.nimbusds.jose.shaded.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Objects;
import com.nimbusds.jose.shaded.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.text.ParseException;
import java.util.List;
import com.nimbusds.jose.shaded.gson.Gson;

public class JSONArrayUtils
{
    private static final Gson GSON;
    
    public static List<Object> parse(final String s) throws ParseException {
        if (s == null) {
            throw new ParseException("The JSON array string must not be null", 0);
        }
        if (s.trim().isEmpty()) {
            throw new ParseException("Invalid JSON array", 0);
        }
        final Type listType = TypeToken.getParameterized(List.class, Object.class).getType();
        try {
            return JSONArrayUtils.GSON.fromJson(s, listType);
        }
        catch (final Exception e) {
            throw new ParseException("Invalid JSON array", 0);
        }
        catch (final StackOverflowError e2) {
            throw new ParseException("Excessive JSON object and / or array nesting", 0);
        }
    }
    
    public static String toJSONString(final List<?> jsonArray) {
        return JSONArrayUtils.GSON.toJson(Objects.requireNonNull(jsonArray));
    }
    
    public static List<Object> newJSONArray() {
        return new ArrayList<Object>();
    }
    
    private JSONArrayUtils() {
    }
    
    static {
        GSON = new GsonBuilder().setStrictness(Strictness.STRICT).serializeNulls().setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE).disableHtmlEscaping().create();
    }
}
