List of usage examples for com.fasterxml.jackson.core JsonToken END_ARRAY
JsonToken END_ARRAY
To view the source code for com.fasterxml.jackson.core JsonToken END_ARRAY.
Click Source Link
From source file:org.datagator.api.client.MatrixDeserializer.java
private static ArrayList<ArrayList<Object>> parseRows(JsonParser jp, int bodyRow, int bodyColumn) throws IOException, JsonProcessingException { ArrayList<ArrayList<Object>> columnHeaders = new ArrayList<ArrayList<Object>>(); int rowIndex = 0; JsonToken token = jp.getCurrentToken(); // START_ARRAY if (!token.equals(JsonToken.START_ARRAY)) { throw new RuntimeException(String.format("Unexpected token %s", token)); }//w w w .j a v a 2s . c o m token = jp.nextToken(); // START_ARRAY while (token.equals(JsonToken.START_ARRAY)) { int columnIndex = 0; if (rowIndex < bodyRow) { ArrayList<Object> rowBuffer = new ArrayList<Object>(); token = jp.nextToken(); while (!token.equals(JsonToken.END_ARRAY)) { rowBuffer.add(jp.getText()); columnIndex += 1; token = jp.nextToken(); } columnHeaders.add(rowBuffer); } else { token = jp.nextToken(); while (!token.equals(JsonToken.END_ARRAY)) { columnIndex += 1; token = jp.nextToken(); } } rowIndex += 1; token = jp.nextToken(); // START_ARRAY } return columnHeaders; }
From source file:org.tanrabad.survey.service.json.MultiPolygonTypeConverter.java
@Override public List<JsonPolygon> parse(JsonParser jsonParser) throws IOException { List<JsonPolygon> polygonList; if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) { polygonList = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { ArrayList<List<Location>> polygon = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { polygon.add(getChildPolygon(jsonParser)); }//from w ww . j av a 2 s . c o m polygonList.add(new JsonPolygon(getBoundary(polygon), getHoles(polygon))); } } else { polygonList = null; } return polygonList; }
From source file:com.basistech.rosette.dm.jackson.array.MorphoAnalysisListArrayDeserializer.java
@Override public List<MorphoAnalysis> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { if (jp.getCurrentToken() != JsonToken.START_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "Expected array of items"); }/*from www . j a v a2 s . c o m*/ List<MorphoAnalysis> results = Lists.newArrayList(); MorphoAnalysisTypes type = MorphoAnalysisTypes.PLAIN; while (jp.nextToken() != JsonToken.END_ARRAY) { if (jp.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) { type = MorphoAnalysisTypes.byOrdinal(jp.getIntValue()); jp.nextToken(); } results.add(jp.readValueAs(type.getMorphoAnalysisClass())); } return ImmutableList.copyOf(results); }
From source file:com.ryan.ryanreader.jsonwrap.JsonBufferedArray.java
@Override protected void buildBuffered(final JsonParser jp) throws IOException { JsonToken jt;//from w ww . j av a 2s .c o m while ((jt = jp.nextToken()) != JsonToken.END_ARRAY) { final JsonValue value = new JsonValue(jp, jt); synchronized (this) { contents.add(value); items++; notifyAll(); } value.buildInThisThread(); } }
From source file:com.amazonaws.hal.client.HalJsonListUnmarshaller.java
@Override public List<Object> unmarshall(JsonUnmarshallerContext context) throws Exception { List<Object> list = new ArrayList<>(); JsonToken token = context.getCurrentToken(); while (token != null && token != JsonToken.END_ARRAY) { if (token.isScalarValue()) { list.add(JsonUnmarshallerUtil.getObjectForToken(token, context)); } else if (token == JsonToken.START_OBJECT) { context.nextToken();/*from w w w . j a va 2 s . co m*/ list.add(HalJsonMapUnmarshaller.getInstance().unmarshall(context)); } else if (token == JsonToken.START_ARRAY) { context.nextToken(); list.add(HalJsonListUnmarshaller.getInstance().unmarshall(context)); } token = context.nextToken(); } return list; }
From source file:javaslang.jackson.datatype.deserialize.OptionDeserializer.java
@Override public Option<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (plainMode) { Object obj = deserializer(0).deserialize(p, ctxt); return Option.of(obj); }/*from ww w . ja v a 2 s . c om*/ boolean defined = false; Object value = null; int cnt = 0; while (p.nextToken() != JsonToken.END_ARRAY) { cnt++; switch (cnt) { case 1: String def = (String) stringDeserializer.deserialize(p, ctxt); if ("defined".equals(def)) { defined = true; } else if ("undefined".equals(def)) { defined = false; } else { throw ctxt.mappingException(javaType.getRawClass()); } break; case 2: value = deserializer(0).deserialize(p, ctxt); break; } } if (defined) { if (cnt != 2) { throw ctxt.mappingException(javaType.getRawClass()); } return Option.some(value); } else { if (cnt != 1) { throw ctxt.mappingException(javaType.getRawClass()); } return Option.none(); } }
From source file:io.swagger.inflector.config.DirectionDeserializer.java
@Override public Set<Configuration.Direction> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.VALUE_FALSE) { return EnumSet.noneOf(Configuration.Direction.class); } else if (token == JsonToken.VALUE_TRUE) { return EnumSet.allOf(Configuration.Direction.class); } else if (token == JsonToken.START_ARRAY) { final Set<Configuration.Direction> items = EnumSet.noneOf(Configuration.Direction.class); while (true) { final JsonToken next = jp.nextToken(); if (next == JsonToken.VALUE_STRING) { final String name = jp.getText(); items.add(Configuration.Direction.valueOf(name)); } else if (next == JsonToken.END_ARRAY) { return items; } else { break; }//w w w . ja v a 2s . c o m } } throw ctxt.mappingException(Configuration.Direction.class); }
From source file:com.taveloper.http.test.pojo.parse.ActivityFeedParse.java
public ActivityFeed readJson(JsonParser in) throws JsonParseException, IOException { // System.out.println("ActivityFeedParse.readJson"); JsonToken curToken = in.nextToken(); ActivityFeed object = new ActivityFeed(); while (curToken == JsonToken.FIELD_NAME) { String curName = in.getText(); JsonToken nextToken = in.nextToken(); if ("items".equals(curName)) { ArrayList<Activity> arrayList = new ArrayList<Activity>(); ActivityParse activityParse = new ActivityParse(); switch (nextToken) { case START_ARRAY: while (in.nextToken() != JsonToken.END_ARRAY) { arrayList.add(activityParse.readJson(in)); }//from w w w. j av a 2 s .c o m break; case START_OBJECT: arrayList.add(activityParse.readJson(in)); break; default: throw new IllegalArgumentException( "unexpected JSON node type: " + nextToken + in.getCurrentName()); } object.setActivities(arrayList); } curToken = in.nextToken(); } return object; }
From source file:com.spotify.ffwd.filter.FilterDeserializer.java
@Override public Filter deserialize(JsonParser p, DeserializationContext ctx) throws IOException, JsonProcessingException { if (p.getCurrentToken() != JsonToken.START_ARRAY) { throw ctx.wrongTokenException(p, JsonToken.START_ARRAY, null); }/*from w ww.j av a 2s . co m*/ final String id = p.nextTextValue(); final PartialDeserializer d = suppliers.get(id); if (d == null) { throw ctx.weirdStringException(id, Filter.class, String.format("Expected one of %s", suppliers.keySet())); } final Filter instance = d.deserialize(p, ctx); if (p.getCurrentToken() != JsonToken.END_ARRAY) { throw ctx.wrongTokenException(p, JsonToken.END_ARRAY, null); } return instance; }
From source file:com.google.openrtb.json.OpenRtbJsonUtils.java
/** * Returns {@code true} if the JSON Object is NOT finished. * Logic is inverted so this is used as a loop-end condition. *//*from ww w . jav a2 s . c o m*/ public static boolean endArray(JsonParser par) { JsonToken token = par.getCurrentToken(); return token != null && token != JsonToken.END_ARRAY; }