Java Code Examples for com.fasterxml.jackson.core.JsonToken
The following examples show how to use
com.fasterxml.jackson.core.JsonToken.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: lams Author: lamsfoundation File: ByteArraySerializer.java License: GNU General Public License v2.0 | 6 votes |
@Override public void serializeWithType(byte[] value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { // most likely scalar WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(value, JsonToken.VALUE_EMBEDDED_OBJECT)); g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); typeSer.writeTypeSuffix(g, typeIdDef); /* OLD impl typeSer.writeTypePrefixForScalar(value, g); g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); typeSer.writeTypeSuffixForScalar(value, g); */ }
Example #2
Source Project: kripton Author: xcesco File: AbstractPrimitiveBindTransform.java License: Apache License 2.0 | 6 votes |
@Override public void generateParseOnJacksonAsString(BindTypeContext context, MethodSpec.Builder methodBuilder, String parserName, TypeName beanClass, String beanName, BindProperty property) { if (nullable && property.isNullable()) { methodBuilder.beginControlFlow("if ($L.currentToken()!=$T.VALUE_NULL)", parserName, JsonToken.class); } if (property.hasTypeAdapter()) { // there's an type adapter methodBuilder.addCode("// using type adapter $L\n", property.typeAdapter.adapterClazz); methodBuilder.addStatement(setter(beanClass, beanName, property, PRE_TYPE_ADAPTER_TO_JAVA + "$T.read$L($L.getText(), $L)" + POST_TYPE_ADAPTER), TypeAdapterUtils.class, TypeUtility.typeName(property.typeAdapter.adapterClazz), PrimitiveUtils.class, PRIMITIVE_UTILITY_TYPE, parserName, DEFAULT_VALUE); } else { // without type adapter methodBuilder.addStatement(setter(beanClass, beanName, property, "$T.read$L($L.getText(), $L)"), PrimitiveUtils.class, PRIMITIVE_UTILITY_TYPE, parserName, DEFAULT_VALUE); } if (nullable && property.isNullable()) { methodBuilder.endControlFlow(); } }
Example #3
Source Project: dropbox-sdk-java Author: dropbox File: JsonReader.java License: MIT License | 6 votes |
/** * Helper to read and parse the optional ".tag" field. If one is found, positions the parser * at the next field (or the closing brace); otherwise leaves the parser position unchanged. * Returns null if there isn't a ".tag" field; otherwise an array of strings (the tags). * Initially the parser must be positioned right after the opening brace. */ public static String[] readTags(JsonParser parser) throws IOException, JsonReadException { if (parser.getCurrentToken() != JsonToken.FIELD_NAME) { return null; } if (!".tag".equals(parser.getCurrentName())) { return null; } parser.nextToken(); if (parser.getCurrentToken() != JsonToken.VALUE_STRING) { throw new JsonReadException("expected a string value for .tag field", parser.getTokenLocation()); } String tag = parser.getText(); parser.nextToken(); return tag.split("\\."); }
Example #4
Source Project: agrest Author: agrestio File: GenericConverter.java License: Apache License 2.0 | 6 votes |
@Override public Object value(JsonNode valueNode) { JsonToken type = valueNode.asToken(); switch (type) { case VALUE_NUMBER_INT: return valueNode.asInt(); case VALUE_NUMBER_FLOAT: return valueNode.asDouble(); case VALUE_TRUE: return Boolean.TRUE; case VALUE_FALSE: return Boolean.FALSE; case VALUE_NULL: return null; default: return valueNode.asText(); } }
Example #5
Source Project: Elasticsearch Author: baidu File: JsonXContentParser.java License: Apache License 2.0 | 6 votes |
@Override public Object objectText() throws IOException { JsonToken currentToken = parser.getCurrentToken(); if (currentToken == JsonToken.VALUE_STRING) { return text(); } else if (currentToken == JsonToken.VALUE_NUMBER_INT || currentToken == JsonToken.VALUE_NUMBER_FLOAT) { return parser.getNumberValue(); } else if (currentToken == JsonToken.VALUE_TRUE) { return Boolean.TRUE; } else if (currentToken == JsonToken.VALUE_FALSE) { return Boolean.FALSE; } else if (currentToken == JsonToken.VALUE_NULL) { return null; } else { return text(); } }
Example #6
Source Project: olingo-odata4 Author: apache File: ClientCsdlLabeledElement.java License: Apache License 2.0 | 6 votes |
@Override protected ClientCsdlLabeledElement doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ClientCsdlLabeledElement element = new ClientCsdlLabeledElement(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { element.setName(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { element.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); } else { element.setValue(jp.readValueAs(ClientCsdlDynamicExpression.class)); } } } return element; }
Example #7
Source Project: agrest Author: agrestio File: CayenneExpParser.java License: Apache License 2.0 | 6 votes |
private static Object extractValue(JsonNode valueNode) { JsonToken type = valueNode.asToken(); switch (type) { case VALUE_NUMBER_INT: return valueNode.asInt(); case VALUE_NUMBER_FLOAT: return valueNode.asDouble(); case VALUE_TRUE: return Boolean.TRUE; case VALUE_FALSE: return Boolean.FALSE; case VALUE_NULL: return null; case START_ARRAY: return extractArray(valueNode); default: // String parameters may need to be parsed further. Defer parsing // until it is placed in the context of an expression... return valueNode; } }
Example #8
Source Project: olingo-odata4 Author: apache File: ClientCsdlIncludeAnnotations.java License: Apache License 2.0 | 6 votes |
@Override protected IncludeAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ClientCsdlIncludeAnnotations member = new ClientCsdlIncludeAnnotations(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("TermNamespace".equals(jp.getCurrentName())) { member.setTermNamespace(jp.nextTextValue()); } else if ("Qualifier".equals(jp.getCurrentName())) { member.setQualifier(jp.nextTextValue()); } else if ("TargetNamespace".equals(jp.getCurrentName())) { member.setTargetNamespace(jp.nextTextValue()); } } } return member; }
Example #9
Source Project: aws-cloudtrail-processing-library Author: aws File: AbstractEventSerializer.java License: Apache License 2.0 | 6 votes |
/** * Parses attributes as a Map<String, Double>, used to parse InsightStatistics * * @return attributes for insight statistics * @throws IOException */ private Map<String, Double> parseAttributesWithDoubleValues() throws IOException { if (jsonParser.nextToken() != JsonToken.START_OBJECT) { throw new JsonParseException("Not an Attributes object", jsonParser.getCurrentLocation()); } Map<String, Double> attributes = new HashMap<>(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { String key = jsonParser.getCurrentName(); Double value = jsonParser.getValueAsDouble(); attributes.put(key, value); } return attributes; }
Example #10
Source Project: spring-cloud-config Author: spring-cloud File: AbstractCipherResourceEncryptor.java License: Apache License 2.0 | 6 votes |
protected String decryptWithJacksonParser(String text, String name, String[] profiles, JsonFactory factory) throws IOException { Set<String> valsToDecrpyt = new HashSet<String>(); JsonParser parser = factory.createParser(text); JsonToken token; while ((token = parser.nextToken()) != null) { if (token.equals(JsonToken.VALUE_STRING) && parser.getValueAsString().startsWith(CIPHER_MARKER)) { valsToDecrpyt.add(parser.getValueAsString().trim()); } } for (String value : valsToDecrpyt) { String decryptedValue = decryptValue(value.replace(CIPHER_MARKER, ""), name, profiles); text = text.replace(value, decryptedValue); } return text; }
Example #11
Source Project: vespa Author: vespa-engine File: VespaSimpleJsonInputFormat.java License: Apache License 2.0 | 6 votes |
@Override public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit fileSplit = (FileSplit) split; FSDataInputStream stream = FileSystem.get(context.getConfiguration()).open(fileSplit.getPath()); if (fileSplit.getStart() != 0) { stream.seek(fileSplit.getStart()); } remaining = fileSplit.getLength(); JsonFactory factory = new JsonFactory().disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES); parser = factory.createParser(new BufferedInputStream(stream)); parser.setCodec(new ObjectMapper()); parser.nextToken(); if (parser.currentToken() == JsonToken.START_ARRAY) { parser.nextToken(); } }
Example #12
Source Project: lams Author: lamsfoundation File: FactoryBasedEnumDeserializer.java License: GNU General Public License v2.0 | 6 votes |
protected Object deserializeEnumUsingPropertyBased(final JsonParser p, final DeserializationContext ctxt, final PropertyBasedCreator creator) throws IOException { PropertyValueBuffer buffer = creator.startBuilding(p, ctxt, null); JsonToken t = p.getCurrentToken(); for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) { String propName = p.getCurrentName(); p.nextToken(); // to point to value SettableBeanProperty creatorProp = creator.findCreatorProperty(propName); if (creatorProp != null) { buffer.assignParameter(creatorProp, _deserializeWithErrorWrapping(p, ctxt, creatorProp)); continue; } if (buffer.readIdProperty(propName)) { continue; } } return creator.build(ctxt, buffer); }
Example #13
Source Project: realworld-serverless-application Author: awslabs File: CreateApplicationResultJsonUnmarshaller.java License: Apache License 2.0 | 6 votes |
public CreateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { CreateApplicationResult createApplicationResult = new CreateApplicationResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return createApplicationResult; } while (true) { if (token == null) break; createApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); token = context.nextToken(); } return createApplicationResult; }
Example #14
Source Project: vavr-jackson Author: vavr-io File: TupleDeserializer.java License: Apache License 2.0 | 6 votes |
@Override public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { List<Object> list = new ArrayList<>(); int ptr = 0; for (JsonToken jsonToken = p.nextToken(); jsonToken != END_ARRAY; jsonToken = p.nextToken()) { if (ptr >= deserializersCount()) { throw mappingException(ctxt, javaType.getRawClass(), jsonToken); } JsonDeserializer<?> deserializer = deserializer(ptr++); Object value = (jsonToken != VALUE_NULL) ? deserializer.deserialize(p, ctxt) : deserializer.getNullValue(ctxt); list.add(value); } if (list.size() == deserializersCount()) { return create(list, ctxt); } else { throw mappingException(ctxt, javaType.getRawClass(), null); } }
Example #15
Source Project: vespa Author: vespa-engine File: MapReader.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "cast", "unchecked" }) public static void fillMapFromObject(TokenBuffer buffer, MapFieldValue parent) { JsonToken token = buffer.currentToken(); int initNesting = buffer.nesting(); expectObjectStart(token); token = buffer.next(); DataType keyType = parent.getDataType().getKeyType(); DataType valueType = parent.getDataType().getValueType(); while (buffer.nesting() >= initNesting) { FieldValue key = readAtomic(buffer.currentName(), keyType); FieldValue value = readSingleValue(buffer, valueType); Preconditions.checkState(key != null && value != null, "Missing key or value for map entry."); parent.put(key, value); token = buffer.next(); } expectObjectEnd(token); }
Example #16
Source Project: heroic Author: spotify File: AggregationOrListDeserializer.java License: Apache License 2.0 | 5 votes |
@Override public AggregationOrList deserialize(final JsonParser p, final DeserializationContext c) throws IOException { switch (p.getCurrentToken()) { case START_ARRAY: final List<Aggregation> chain = p.readValueAs(LIST_OF_AGGREGATIONS); return new AggregationOrList(Aggregations.chain(chain)); case START_OBJECT: return new AggregationOrList(Optional.of(p.readValueAs(Aggregation.class))); default: throw c.wrongTokenException(p, JsonToken.START_OBJECT, null); } }
Example #17
Source Project: emodb Author: bazaarvoice File: AbstractEmoFieldUDF.java License: Apache License 2.0 | 5 votes |
/** * Don't materialize the entire parser content, do a targeted search for the value that matches the path. */ private boolean moveParserToField(JsonParser parser, String path) throws IOException { List<String> segments = getFieldPath(path); for (String segment : segments) { if (parser.getCurrentToken() != JsonToken.START_OBJECT) { // Always expect the path to be fields in a JSON map return false; } boolean found = false; JsonToken currentToken = parser.nextToken(); while (!found && currentToken != JsonToken.END_OBJECT) { if (currentToken != JsonToken.FIELD_NAME) { // This should always be a field. Something is amiss. throw new IOException("Field not found at expected location"); } String fieldName = parser.getText(); if (fieldName.equals(segment)) { // Move to the next token, which is the field value found = true; currentToken = parser.nextToken(); } else { parser.nextValue(); currentToken = skipValue(parser); } } if (!found) { // Field was not found return false; } } // The current location in the parser is the value. return true; }
Example #18
Source Project: kripton Author: xcesco File: BindBeanSharedPreferences.java License: Apache License 2.0 | 5 votes |
/** * for attribute valueCharacterSet parsing */ protected Set<Character> parseValueCharacterSet(String input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Set<Character> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Character> collection=new HashSet<>(); Character item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=Character.valueOf((char)jacksonParser.getIntValue()); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example #19
Source Project: jackson-datatypes-collections Author: FasterXML File: BaseRefCollectionDeserializer.java License: Apache License 2.0 | 5 votes |
@Override protected void add(Intermediate intermediate, JsonParser parser, DeserializationContext ctx) throws IOException { Object value; if (parser.currentToken() == JsonToken.VALUE_NULL) { value = null; } else if (_typeDeserializerForValue == null) { value = _valueDeserializer.deserialize(parser, ctx); } else { value = _valueDeserializer.deserializeWithType(parser, ctx, _typeDeserializerForValue); } intermediate.add(value); }
Example #20
Source Project: dremio-oss Author: dremio File: JSONElementLocator.java License: Apache License 2.0 | 5 votes |
private void updatePath(JsonToken token) throws IOException { switch (token) { case START_ARRAY: inc(); pushArray(); break; case END_ARRAY: popArray(); break; case START_OBJECT: inc(); pushObject(null); break; case END_OBJECT: popObject(); break; case FIELD_NAME: popObject(); currentField = parser.getText(); pushObject(currentField); break; case VALUE_EMBEDDED_OBJECT: case VALUE_FALSE: case VALUE_NULL: case VALUE_NUMBER_FLOAT: case VALUE_NUMBER_INT: case VALUE_STRING: case VALUE_TRUE: inc(); break; case NOT_AVAILABLE: default: throw new IllegalStateException(token + " " + path); } }
Example #21
Source Project: deprecated-security-advanced-modules Author: opendistro-for-elasticsearch File: AbstractConfigurationValidator.java License: Apache License 2.0 | 5 votes |
private boolean checkDatatypes() throws Exception { String contentAsJson = XContentHelper.convertToJson(content, false, XContentType.JSON); try (JsonParser parser = factory.createParser(contentAsJson)) { JsonToken token = null; while ((token = parser.nextToken()) != null) { if (token.equals(JsonToken.FIELD_NAME)) { String currentName = parser.getCurrentName(); DataType dataType = allowedKeys.get(currentName); if (dataType != null) { JsonToken valueToken = parser.nextToken(); switch (dataType) { case STRING: if (!valueToken.equals(JsonToken.VALUE_STRING)) { wrongDatatypes.put(currentName, "String expected"); } break; case ARRAY: if (!valueToken.equals(JsonToken.START_ARRAY) && !valueToken.equals(JsonToken.END_ARRAY)) { wrongDatatypes.put(currentName, "Array expected"); } break; case OBJECT: if (!valueToken.equals(JsonToken.START_OBJECT) && !valueToken.equals(JsonToken.END_OBJECT)) { wrongDatatypes.put(currentName, "Object expected"); } break; } } } } return wrongDatatypes.isEmpty(); } }
Example #22
Source Project: kripton Author: xcesco File: Bean2Table.java License: Apache License 2.0 | 5 votes |
/** * for attribute valueEnumTypeSet parsing */ public static HashSet<EnumType> parseValueEnumTypeSet(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); HashSet<EnumType> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<EnumType> collection=new HashSet<>(); EnumType item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { { String tempEnum=jacksonParser.getText(); item=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null; } } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example #23
Source Project: CloverETL-Engine Author: CloverETL File: JsonSaxParser.java License: GNU Lesser General Public License v2.1 | 5 votes |
public void convertJSON2XML(Reader in,Writer out,boolean firstObjectOnly,boolean suppresNodeValues)throws IOException, SAXException{ this.handler=new JSON2XMLHandler(out,suppresNodeValues); JsonParser parser; try { parser = JSON_FACTORY.createJsonParser(in); } catch (JsonParseException e) { throw new IOException(e); } Deque<JsonToken> tokens = new ArrayDeque<JsonToken>(); Deque<String> names = new ArrayDeque<String>(); Deque<Integer> depthCounter = new ArrayDeque<Integer>(); depthCounter.add(0); JsonToken currentToken = null; xmlEscapeChars=true; handler.startDocument(); int startEndCounter = 0; while ((currentToken = parser.nextToken()) != null) { processToken(currentToken, parser, tokens, names, depthCounter); if (currentToken == JsonToken.START_ARRAY || currentToken == JsonToken.START_OBJECT) { startEndCounter++; } else if (currentToken == JsonToken.END_ARRAY || currentToken == JsonToken.END_OBJECT) { startEndCounter--; } if (startEndCounter == 0) { break; } } handler.endDocument(); }
Example #24
Source Project: ojai Author: ojai File: JsonStreamDocumentReader.java License: Apache License 2.0 | 5 votes |
JsonStreamDocumentReader(JsonDocumentStream stream) { containerStack = new Stack<ContainerContext>(); cachedTokens = new LinkedList<JsonToken>(); documentStream = stream; mapLevel = 0; eor = false; }
Example #25
Source Project: aws-cloudtrail-processing-library Author: aws File: AbstractEventSerializer.java License: Apache License 2.0 | 5 votes |
/** * Read the header of an AWS CloudTrail log. * * @throws JsonParseException if the log could not be parsed. * @throws IOException if the log could not be opened or accessed. */ protected void readArrayHeader() throws IOException { if (jsonParser.nextToken() != JsonToken.START_OBJECT) { throw new JsonParseException("Not a Json object", jsonParser.getCurrentLocation()); } jsonParser.nextToken(); if (!jsonParser.getText().equals(RECORDS)) { throw new JsonParseException("Not a CloudTrail log", jsonParser.getCurrentLocation()); } if (jsonParser.nextToken() != JsonToken.START_ARRAY) { throw new JsonParseException("Not a CloudTrail log", jsonParser.getCurrentLocation()); } }
Example #26
Source Project: openrtb Author: google File: OpenRtbJsonUtils.java License: Apache License 2.0 | 5 votes |
/** * Starts an Object, skipping the '{' token, and if necessary a field name before it. */ public static void startObject(JsonParser par) throws IOException { JsonToken token = par.getCurrentToken(); if (token == null || token == JsonToken.FIELD_NAME) { token = par.nextToken(); } if (token == JsonToken.START_OBJECT) { par.nextToken(); } else { throw new JsonParseException(par, "Expected start of object"); } }
Example #27
Source Project: timely Author: NationalSecurityAgency File: SuggestResponse.java License: Apache License 2.0 | 5 votes |
@Override public SuggestResponse deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { SuggestResponse response = new SuggestResponse(); if (p.getCurrentToken() == JsonToken.START_ARRAY) { while (p.nextToken() != JsonToken.END_ARRAY) { response.addSuggestion(p.getValueAsString()); } } return response; }
Example #28
Source Project: kripton Author: xcesco File: BeanDaoImpl.java License: Apache License 2.0 | 5 votes |
/** * for param parser1 parsing */ private BeanInner[] parser1(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); BeanInner[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<BeanInner> collection=new ArrayList<>(); BeanInner item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=beanInnerBindMap.parseOnJackson(jacksonParser); } collection.add(item); } result=CollectionUtils.asArray(collection, new BeanInner[collection.size()]); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example #29
Source Project: jackson-datatype-protobuf Author: HubSpot File: CustomDeserializerTest.java License: Apache License 2.0 | 5 votes |
public CustomDeserializer() { addDeserializer(Custom.class, new JsonDeserializer<Custom>() { @Override public Custom deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { assertThat(p.getCurrentToken()).isEqualTo(JsonToken.VALUE_NUMBER_INT); return Custom.newBuilder().setValue(p.getIntValue()).build(); } }); }
Example #30
Source Project: jackson-datatypes-collections Author: FasterXML File: BaseCharCollectionDeserializer.java License: Apache License 2.0 | 5 votes |
@Override public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { Intermediate intermediate = createIntermediate(); if (p.isExpectedStartArrayToken()) { JsonToken t; while ((t = p.nextToken()) != JsonToken.END_ARRAY) { String str; if (t == JsonToken.VALUE_STRING) { str = p.getText(); } else { CharSequence cs = (CharSequence) ctxt.handleUnexpectedToken(getValueType(ctxt), p); str = cs.toString(); } if (str.length() != 1) { ctxt.reportInputMismatch(this, "Cannot convert a JSON String of length %d into a char element of " + "char array", str.length()); } add(intermediate, str.charAt(0)); } return finish(intermediate); } char[] chars = p.getTextCharacters(); addAll(intermediate, chars, p.getTextOffset(), p.getTextLength()); return finish(intermediate); }