json - Is it possible to skip or ignore a attribute while using Streaming API of Jackson -


this json source. can skip retweeted_status token , move next contributors token (not 1 inside retweeted_status token).

currently following code goes retweeted_status object , parsing each 1 of them:

jp = jsonf.createjsonparser(strline); if (jp.nexttoken() != jsontoken.start_object) {         throw new ioexception("expected data start object");     }     twitterentry result = new twitterentry();     // iterate on object fields:     while (jp.nexttoken() != jsontoken.end_object) {         string fieldname = jp.getcurrentname();         // let's move value         jp.nexttoken();         if (fieldname.equals("id")) {             result.setid(jp.getlongvalue());         } else if (fieldname.equals("text")) {             result.settext(jp.gettext());         } else if (fieldname.equals("fromuserid")) {             result.setfromuserid(jp.getintvalue());         } else if (fieldname.equals("touserid")) {             result.settouserid(jp.getintvalue());         } else if (fieldname.equals("languagecode")) {             result.setlanguagecode(jp.gettext());         } else { // ignore, or signal error?             //ignoring unrecognized fields             //throw new ioexception("unrecognized field '"+fieldname+"'");         }     }     jp.close(); 

you should able use jp.skipchildren() in else statement.

ie

... else {    jp.nexttoken();  // go value token    jp.skipchildren();  // skip if object or array } ... 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -