<commit_before>package com.thebluealliance.androidclient.datafeed;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.thebluealliance.androidclient.datafeed.deserializers.AwardDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.EventDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.MatchDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.MediaDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.TeamDeserializer;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.Match;
import com.thebluealliance.androidclient.models.Media;
import com.thebluealliance.androidclient.models.Team;

/**
 * File created by phil on 4/22/14.
 */
public class JSONManager {
    private static Gson gson;
    private static JsonParser parser;

    public static JsonParser getParser() {
        if (parser == null)
            parser = new JsonParser();
        return parser;
    }

    public static Gson getGson() {
        if (gson == null) {
            /* Construct new gson with our custom deserializers */
            GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapter(Award.class, new AwardDeserializer());
            builder.registerTypeAdapter(Event.class, new EventDeserializer());
            builder.registerTypeAdapter(Match.class, new MatchDeserializer());
            builder.registerTypeAdapter(Team.class, new TeamDeserializer());
            builder.registerTypeAdapter(Media.class, new MediaDeserializer());
            gson = builder.create();
        }
        return gson;
    }

    public static JsonObject getasJsonObject(String input) {
        if (input == null || input.equals(""))
            return new JsonObject();
        JsonElement e = getParser().parse(input);
        if (e == null || e.isJsonNull()) {
            return new JsonObject();
        }
        return e.getAsJsonObject();
    }

    public static JsonArray getasJsonArray(String input) {
        if (input == null || input.equals(""))
            return new JsonArray();
        return getParser().parse(input).getAsJsonArray();
    }
}
<commit_msg>catch json exceptions<commit_after>package com.thebluealliance.androidclient.datafeed;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.thebluealliance.androidclient.Constants;
import com.thebluealliance.androidclient.datafeed.deserializers.AwardDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.EventDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.MatchDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.MediaDeserializer;
import com.thebluealliance.androidclient.datafeed.deserializers.TeamDeserializer;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.Match;
import com.thebluealliance.androidclient.models.Media;
import com.thebluealliance.androidclient.models.Team;

/**
 * File created by phil on 4/22/14.
 */
public class JSONManager {
    private static Gson gson;
    private static JsonParser parser;

    public static JsonParser getParser() {
        if (parser == null)
            parser = new JsonParser();
        return parser;
    }

    public static Gson getGson() {
        if (gson == null) {
            /* Construct new gson with our custom deserializers */
            GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapter(Award.class, new AwardDeserializer());
            builder.registerTypeAdapter(Event.class, new EventDeserializer());
            builder.registerTypeAdapter(Match.class, new MatchDeserializer());
            builder.registerTypeAdapter(Team.class, new TeamDeserializer());
            builder.registerTypeAdapter(Media.class, new MediaDeserializer());
            gson = builder.create();
        }
        return gson;
    }

    public static JsonObject getasJsonObject(String input) {
        if (input == null || input.equals(""))
            return new JsonObject();
        JsonElement e = getParser().parse(input);
        if (e == null || e.isJsonNull()) {
            return new JsonObject();
        }
        try {
            return e.getAsJsonObject();
        } catch (IllegalStateException err) {
            Log.w(Constants.LOG_TAG, "getAsJsonObject failed: " + err);
            return new JsonObject();
        }
    }

    public static JsonArray getasJsonArray(String input) {
        if (input == null || input.equals(""))
            return new JsonArray();
        try {
            return getParser().parse(input).getAsJsonArray();
        } catch (IllegalStateException err) {
            Log.w(Constants.LOG_TAG, "getAsJsonArray failed: " + err);
            return new JsonArray();
        }
    }
}

{'fraction_non_alphanumeric': 0.10071267816954238, 'fraction_numerical': 0.0018754688672168042, 'mean_word_length': 3.262989608313349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5939521', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1471, 'n_words': 304}