Buggy code:
public class JsonParser { private static final int REVENUE_LAST_30DAYS = 30 ; private static final int REVENUE_LAST_7DAYS = 7 ; private static final int REVENUE_LAST_DAY = 1 ; private static final int REVENUE_OVERALL = - 1 ; private static final String TAG = JsonParser . class . getSimpleName ( ) ; private static final boolean DEBUG = false ; private JsonParser ( ) { } static void parseRatings ( String json , AppStats stats ) throws JSONException { } static void parseStatistics ( String json , AppStats stats , int statsType ) throws JSONException { } static List < AppInfo > parseAppInfos ( String json , String accountName , boolean skipIncomplete ) throws JSONException { Date now = new Date ( ) ; List < AppInfo > apps = new ArrayList < AppInfo > ( ) ; JSONObject result = new JSONObject ( json ) . getJSONObject ( "result" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "result" , result ) ; } JSONArray jsonApps = result . optJSONArray ( "1" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "jsonApps" , jsonApps ) ; } if ( jsonApps == null ) { return apps ; } int numberOfApps = jsonApps . length ( ) ; Log . d ( JsonParser . TAG , String . format ( "Found<seq2seq4repair_space>%d<seq2seq4repair_space>apps<seq2seq4repair_space>in<seq2seq4repair_space>JSON" , numberOfApps ) ) ; for ( int i = 0 ; i < numberOfApps ; i ++ ) { AppInfo app = new AppInfo ( ) ; app . setAccount ( accountName ) ; app . setLastUpdate ( now ) ; JSONObject jsonApp = jsonApps . getJSONObject ( i ) ; JSONObject jsonAppInfo = jsonApp . getJSONObject ( "1" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "jsonAppInfo" , jsonAppInfo ) ; } String packageName = jsonAppInfo . getString ( "1" ) ; if ( ( packageName == null ) || ( ( packageName . startsWith ( "tmp." ) ) && ( Character . isDigit ( packageName . charAt ( 4 ) ) ) ) ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>draft<seq2seq4repair_space>app<seq2seq4repair_space>%d,<seq2seq4repair_space>package<seq2seq4repair_space>name=%s" , i , packageName ) ) ; continue ; } int publishState = jsonAppInfo . optInt ( "7" ) ; Log . d ( JsonParser . TAG , String . format ( "%s:<seq2seq4repair_space>publishState=%d" , packageName , publishState ) ) ; if ( publishState != 1 ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>app<seq2seq4repair_space>%d<seq2seq4repair_space>with<seq2seq4repair_space>state<seq2seq4repair_space>!=<seq2seq4repair_space>1:<seq2seq4repair_space>package<seq2seq4repair_space>name=%s:<seq2seq4repair_space>state=%d" , i , packageName , publishState ) ) ; continue ; } app . setPublishState ( publishState ) ; app . setPackageName ( packageName ) ; if ( ! ( jsonAppInfo . has ( "2" ) ) ) { if ( skipIncomplete ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>app<seq2seq4repair_space>%d<seq2seq4repair_space>because<seq2seq4repair_space>no<seq2seq4repair_space>app<seq2seq4repair_space>details<seq2seq4repair_space>found:<seq2seq4repair_space>package<seq2seq4repair_space>name=%s" , i , packageName ) ) ; } else { Log . d ( JsonParser . TAG , ( "Adding<seq2seq4repair_space>incomplete<seq2seq4repair_space>app:<seq2seq4repair_space>" + packageName ) ) ; apps . add ( app ) ; } continue ; } if ( ! ( jsonAppInfo . has ( "4" ) ) ) { if ( skipIncomplete ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>app<seq2seq4repair_space>%d<seq2seq4repair_space>because<seq2seq4repair_space>no<seq2seq4repair_space>versions<seq2seq4repair_space>info<seq2seq4repair_space>found:<seq2seq4repair_space>package<seq2seq4repair_space>name=%s" , i , packageName ) ) ; } else { Log . d ( JsonParser . TAG , ( "Adding<seq2seq4repair_space>incomplete<seq2seq4repair_space>app:<seq2seq4repair_space>" + packageName ) ) ; apps . add ( app ) ; } continue ; } JSONObject appDetails = jsonAppInfo . getJSONObject ( "2" ) . getJSONArray ( "1" ) . getJSONObject ( 0 ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "appDetails" , appDetails ) ; } app . setName ( appDetails . getString ( "2" ) ) ; <START_BUG> String description = appDetails . getString ( "3" ) ; <END_BUG> String changelog = appDetails . optString ( "5" ) ; Long lastPlayStoreUpdate = jsonAppInfo . getJSONObject ( "11" ) . getLong ( "1" ) ; AppDetails details = new AppDetails ( description , changelog , lastPlayStoreUpdate ) ; app . setDetails ( details ) ; JSONArray appVersions = jsonAppInfo . getJSONObject ( "4" ) . getJSONObject ( "1" ) . optJSONArray ( "1" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "appVersions" , appVersions ) ; } if ( appVersions == null ) { if ( skipIncomplete ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>app<seq2seq4repair_space>%d<seq2seq4repair_space>because<seq2seq4repair_space>no<seq2seq4repair_space>versions<seq2seq4repair_space>info<seq2seq4repair_space>found:<seq2seq4repair_space>package<seq2seq4repair_space>name=%s" , i , packageName ) ) ; } else { Log . d ( JsonParser . TAG , ( "Adding<seq2seq4repair_space>incomplete<seq2seq4repair_space>app:<seq2seq4repair_space>" + packageName ) ) ; apps . add ( app ) ; } continue ; } JSONObject lastAppVersionDetails = appVersions . getJSONObject ( ( ( appVersions . length ( ) ) - 1 ) ) . getJSONObject ( "2" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "lastAppVersionDetails" , lastAppVersionDetails ) ; } app . setVersionName ( lastAppVersionDetails . getString ( "4" ) ) ; app . setIconUrl ( lastAppVersionDetails . getJSONObject ( "6" ) . getString ( "3" ) ) ; JSONObject jsonAppStats = jsonApp . optJSONObject ( "3" ) ; if ( JsonParser . DEBUG ) { JsonParser . pp ( "jsonAppStats" , jsonAppStats ) ; } if ( jsonAppStats == null ) { if ( skipIncomplete ) { Log . d ( JsonParser . TAG , String . format ( "Skipping<seq2seq4repair_space>app<seq2seq4repair_space>%d<seq2seq4repair_space>because<seq2seq4repair_space>no<seq2seq4repair_space>stats<seq2seq4repair_space>found:<seq2seq4repair_space>package<seq2seq4repair_space>name=%s" , i , packageName ) ) ; } else { Log . d ( JsonParser . TAG , ( "Adding<seq2seq4repair_space>incomplete<seq2seq4repair_space>app:<seq2seq4repair_space>" + packageName ) ) ; apps . add ( app ) ; } continue ; } AppStats stats = new AppStats ( ) ; stats . setDate ( now ) ; if ( ( jsonAppStats . length ( ) ) < 4 ) { stats . setActiveInstalls ( 0 ) ; stats . setTotalDownloads ( 0 ) ; stats . setNumberOfErrors ( 0 ) ; }

Fix:
String description = appDetails . optString ( "3" ) ;