@Test public void parserCharacter() throws IOException, JsonFormatException { String json = "[\"a\",null,\"c\"]"; JsonPullParser parser = JsonPullParser.newParser(json); State state = parser.getEventType(); assertThat(state, is(State.START_ARRAY)); assertThat(JsonParseUtil.parserCharacter(parser), is('a')); assertThat(JsonParseUtil.parserCharacter(parser), nullValue()); assertThat(JsonParseUtil.parserCharacter(parser), is('c')); }
public static Character parserCharacter(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } else if (eventType == State.VALUE_STRING) { String str = parser.getValueString(); if (str.length() != 1) { throw new IllegalStateException( "unexpected value. expecte string size is 1. but get=" + str); } return str.charAt(0); } else { throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get=" + eventType.toString()); } }
JsonParseUtil { public static Character parserCharacter(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } else if (eventType == State.VALUE_STRING) { String str = parser.getValueString(); if (str.length() != 1) { throw new IllegalStateException( "unexpected value. expecte string size is 1. but get=" + str); } return str.charAt(0); } else { throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get=" + eventType.toString()); } } }
JsonParseUtil { public static Character parserCharacter(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } else if (eventType == State.VALUE_STRING) { String str = parser.getValueString(); if (str.length() != 1) { throw new IllegalStateException( "unexpected value. expecte string size is 1. but get=" + str); } return str.charAt(0); } else { throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get=" + eventType.toString()); } }  }
JsonParseUtil { public static Character parserCharacter(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } else if (eventType == State.VALUE_STRING) { String str = parser.getValueString(); if (str.length() != 1) { throw new IllegalStateException( "unexpected value. expecte string size is 1. but get=" + str); } return str.charAt(0); } else { throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get=" + eventType.toString()); } }  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); }
JsonParseUtil { public static Character parserCharacter(JsonPullParser parser) throws IOException, JsonFormatException { State eventType = parser.getEventType(); if (eventType == State.VALUE_NULL) { return null; } else if (eventType == State.VALUE_STRING) { String str = parser.getValueString(); if (str.length() != 1) { throw new IllegalStateException( "unexpected value. expecte string size is 1. but get=" + str); } return str.charAt(0); } else { throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get=" + eventType.toString()); } }  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);  }