JsonPullParser { public State lookAhead() throws IOException, JsonFormatException { if (lookAhead == null) { lookAhead = getEventType(); } return lookAhead; } JsonPullParser(); static JsonPullParser newParser(InputStream is); static JsonPullParser newParser(InputStream is, String charsetName); static JsonPullParser newParser(InputStream is, Charset charset); static JsonPullParser newParser(String json); static JsonPullParser newParser(Reader reader); JsonPullParser setLogEnable(); State lookAhead(); State getEventType(); int getSliceSize(); void discardValue(); void discardArrayToken(); void discardHashToken(); String getValueString(); long getValueLong(); double getValueDouble(); boolean getValueBoolean(); boolean isLogEnabled(); List<JsonSlice> getSlices(); static final String DEFAULT_CHARSET_NAME; static final Charset DEFAULT_CHARSET; }
@Test public void lookAhead() throws IOException, JsonFormatException { State type; JsonPullParser parser = JsonPullParser .newParser("[\"value1\", 2, 0.1 ,true ,{\"test1\":1, \"test2\":null \n } ,null]"); type = parser.lookAhead(); assertThat(type, is(State.START_ARRAY)); type = parser.lookAhead(); assertThat(type, is(State.START_ARRAY)); type = parser.getEventType(); assertThat(type, is(State.START_ARRAY)); type = parser.lookAhead(); assertThat(type, is(State.VALUE_STRING)); type = parser.getEventType(); assertThat(type, is(State.VALUE_STRING)); type = parser.getEventType(); assertThat(type, is(State.VALUE_LONG)); }