Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonParser#getCurrentName()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonParser#getCurrentName() .
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 File: HugeResource.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public HugeResource deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException { HugeResource res = new HugeResource(); while (parser.nextToken() != JsonToken.END_OBJECT) { String key = parser.getCurrentName(); if (key.equals("type")) { if (parser.nextToken() != JsonToken.VALUE_NULL) { res.type = ctxt.readValue(parser, ResourceType.class); } else { res.type = null; } } else if (key.equals("label")) { if (parser.nextToken() != JsonToken.VALUE_NULL) { res.label = parser.getValueAsString(); } else { res.label = null; } } else if (key.equals("properties")) { if (parser.nextToken() != JsonToken.VALUE_NULL) { @SuppressWarnings("unchecked") Map<String, Object> prop = ctxt.readValue(parser, Map.class); res.properties = prop; } else { res.properties = null; } } } res.checkFormat(); return res; }
Example 2
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); vp.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); vp.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); vp.setValue(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String key = jsonParser.getCurrentName(); jsonParser.nextToken(); final Object val = deserializationContext.readValue(jsonParser, Object.class); vp.addProperty(new DetachedProperty(key, val)); } } } return vp.create(); }
Example 3
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }
Example 4
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }
Example 5
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); vp.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); vp.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); vp.setValue(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String key = jsonParser.getCurrentName(); jsonParser.nextToken(); final Object val = deserializationContext.readValue(jsonParser, Object.class); vp.addProperty(new DetachedProperty(key, val)); } } } return vp.create(); }