JsonParseUtil { public static List<Float> parserFloatList(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } if (eventType != State.START_ARRAY) { throw new IllegalStateException("not started brace!"); } List<Float> list = new ArrayList<Float>(); while (parser.lookAhead() != State.END_ARRAY) { eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { list.add(null); } else if (eventType == State.VALUE_DOUBLE) { list.add((float) parser.getValueDouble()); } else { throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get=" + eventType.toString()); } } parser.getEventType(); return list; }  static Integer parserInteger(JsonPullParser parser); static Long parserLong(JsonPullParser parser); static Byte parserByte(JsonPullParser parser); static Short parserShort(JsonPullParser parser); static Boolean parserBoolean(JsonPullParser parser); static Character parserCharacter(JsonPullParser parser); static Double parserDouble(JsonPullParser parser); static Float parserFloat(JsonPullParser parser); static List<Integer> parserIntegerList(JsonPullParser parser); static List<Long> parserLongList(JsonPullParser parser); static List<Byte> parserByteList(JsonPullParser parser); static List<Short> parserShortList(JsonPullParser parser); static List<Boolean> parserBooleanList(JsonPullParser parser); static List<Character> parserCharacterList(JsonPullParser parser); static List<Double> parserDoubleList(JsonPullParser parser); static List<Float> parserFloatList(JsonPullParser parser); static List<String> parserStringList(JsonPullParser parser); static List<Date> parserDateList(JsonPullParser parser); static List<T> parserEnumList(JsonPullParser parser, Class<T> clazz);  }
@Test public void parserFloatList() throws IOException, JsonFormatException { String json = "[0.0,null,2.2,3.3,4.4]"; JsonPullParser parser = JsonPullParser.newParser(json); List<Float> list = JsonParseUtil.parserFloatList(parser); assertThat(list.size(), is(5)); assertThat(list.get(0), is(0.0F)); assertThat(list.get(1), nullValue()); assertThat(list.get(2), is(2.2F)); assertThat(list.get(3), is(3.3F)); assertThat(list.get(4), is(4.4F)); }