public List < MixedListingElement > parse ( String jsonText ) throws RedditParseException { // Parse to a list of things List < Thing > things = this . parseGeneric ( jsonText ) ; // List of comment and submission mixed elements List < MixedListingElement > mixedElements = new LinkedList < MixedListingElement > ( ) ; // Iterate over things for ( Thing t : things ) { if ( t instanceof Comment ) { mixedElements . add ( ( Comment ) t ) ; } else if ( t instanceof Submission ) { mixedElements . add ( ( Submission ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } // Return result return mixedElements ; }
Parse JSON received from reddit into a list of submissions and comments . This parser expects the JSON to be of a listing of submissions and comments .