Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonParser


  }

  public AstNode parse(String className, Reader reader) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory factory = mapper.getFactory();
    JsonParser parser = factory.createJsonParser(reader);
    String xName = className + System.currentTimeMillis();
    stack.add(new AstNode(xName, null, false)); //artificial root element - must stay on the top of the Stack
    doField(className, parser);
    if (!xName.equals(stack.peek().getName())) {
      throw new IllegalStateException("Artificial element " + xName + " not found on the top of the stack");
View Full Code Here


    private static boolean isValidJson(String json)
    {
        boolean valid = false;
        try {
            JsonParser parser = new ObjectMapper().getFactory()
                    .createJsonParser(json);
            continueWhileNotNull(parser, parser.nextToken());
            valid = true;
        }
        catch (IOException ignored) {
        }
        return valid;
View Full Code Here

    private static String doExtract(JsonExtractor<Slice> jsonExtractor, String json)
            throws IOException
    {
        JsonFactory jsonFactory = new JsonFactory();
        JsonParser jsonParser = jsonFactory.createJsonParser(json);
        jsonParser.nextToken(); // Advance to the first token
        Slice extract = jsonExtractor.extract(jsonParser);
        return (extract == null) ? null : extract.toString(Charsets.UTF_8);
    }
View Full Code Here

    {
        // First: add closing END_OBJECT as marker
        unknownTokens.writeEndObject();
       
        // note: buffer does NOT have starting START_OBJECT
        JsonParser bufferParser = unknownTokens.asParser();
        while (bufferParser.nextToken() != JsonToken.END_OBJECT) {
            String propName = bufferParser.getCurrentName();
            // Unknown: let's call handler method
            bufferParser.nextToken();
            handleUnknownProperty(bufferParser, ctxt, bean, propName);
        }
        return bean;
    }
View Full Code Here

    private static String doExtract(JsonExtractor jsonExtractor, String json)
            throws IOException
    {
        JsonFactory jsonFactory = new JsonFactory();
        JsonParser jsonParser = jsonFactory.createJsonParser(json);
        jsonParser.nextToken(); // Advance to the first token
        Slice extract = jsonExtractor.extract(jsonParser);
        return (extract == null) ? null : extract.toString(Charsets.UTF_8);
    }
View Full Code Here

      @Override
      protected boolean matchesSafely(File item) {
        boolean valid = false;
        try {
          JsonParser parser = new ObjectMapper().getFactory().createParser(item);
          while (parser.nextToken() != null) {
          }
          valid = true;
        } catch (IOException e) {
          throw new AssertionError(e);
        }
View Full Code Here

    /**
     * Creates a vertex from GraphSON using settings supplied in the constructor.
     */
    public Vertex vertexFromJson(final String json) throws IOException {
        final JsonParser jp = jsonFactory.createParser(json);
        final JsonNode node = jp.readValueAsTree();
        return this.vertexFromJson(node);
    }
View Full Code Here

    /**
     * Creates a vertex from GraphSON using settings supplied in the constructor.
     */
    public Vertex vertexFromJson(final InputStream json) throws IOException {
        final JsonParser jp = jsonFactory.createParser(json);
        final JsonNode node = jp.readValueAsTree();
        return this.vertexFromJson(node);
    }
View Full Code Here

    /**
     * Creates an edge from GraphSON using settings supplied in the constructor.
     */
    public Edge edgeFromJson(final String json, final Vertex out, final Vertex in) throws IOException {
        final JsonParser jp = jsonFactory.createParser(json);
        final JsonNode node = jp.readValueAsTree();
        return this.edgeFromJson(node, out, in);
    }
View Full Code Here

    /**
     * Creates an edge from GraphSON using settings supplied in the constructor.
     */
    public Edge edgeFromJson(final InputStream json, final Vertex out, final Vertex in) throws IOException {
        final JsonParser jp = jsonFactory.createParser(json);
        final JsonNode node = jp.readValueAsTree();
        return this.edgeFromJson(node, out, in);
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.core.JsonParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.