Example usage for com.fasterxml.jackson.core JsonFactory createJsonParser

List of usage examples for com.fasterxml.jackson.core JsonFactory createJsonParser

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonFactory createJsonParser.

Prototype

@Deprecated
public JsonParser createJsonParser(String content) throws IOException, JsonParseException 

Source Link

Document

Method for constructing parser for parsing contents of given String.

Usage

From source file:com.pursuer.reader.easyrss.data.parser.ItemIdJSONParser.java

public ItemIdJSONParser(final InputStream input) throws JsonParseException, IOException {
    final JsonFactory factory = new JsonFactory();
    this.parser = factory.createJsonParser(input);
}

From source file:KV78Tester.java

public String[] parseLines(BufferedReader in) throws Exception {
    JsonFactory f = new JsonFactory();
    JsonParser jp = f.createJsonParser(in);
    ArrayList<String> lines = new ArrayList<String>();
    jp.nextToken();/*w  w  w  .j av a 2 s. co  m*/
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String line = jp.getCurrentName();
        lines.add(line);
        jp.nextToken();
    }
    jp.close();
    in.close();
    return lines.toArray(new String[lines.size()]);
}

From source file:com.pursuer.reader.easyrss.data.parser.UnreadCountJSONParser.java

public UnreadCountJSONParser(final byte[] content) throws JsonParseException, IOException {
    final JsonFactory factory = new JsonFactory();
    this.parser = factory.createJsonParser(content);
}

From source file:com.pursuer.reader.easyrss.data.parser.UnreadCountJSONParser.java

public UnreadCountJSONParser(final InputStream input) throws JsonParseException, IOException {
    final JsonFactory factory = new JsonFactory();
    this.parser = factory.createJsonParser(input);
}

From source file:KV78Tester.java

public void checkLines(BufferedReader in) throws JsonParseException, IOException {
    JsonFactory f = new JsonFactory();
    JsonParser jp = f.createJsonParser(in);
    String line = "";
    jp.nextToken();//from w  ww.  ja v  a  2  s  . c  om
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String namefield = jp.getCurrentName();
        if (namefield != null && namefield.contains("_")) {
            line = namefield;
        }
        jp.nextToken();
        if ("Actuals".equals(namefield)) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                jp.getCurrentName();
                jp.nextToken();
                while (jp.nextToken() != JsonToken.END_OBJECT) {
                    jp.nextToken();
                }
            }
        } else if ("Network".equals(namefield)) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                int userstop = Integer.parseInt(jp.getCurrentName());
                jp.nextToken();
                checkStop(jp, line, userstop);
            }
        }
    }
}

From source file:uk.ac.soton.itinnovation.sad.service.domain.JsonResponse.java

public JsonResponse(String result, JSONObject response) {
    this.result = result;
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(Include.NON_NULL);
    JsonFactory factory = mapper.getJsonFactory();
    try {//from   w w w  .j  a v a  2 s. co m
        JsonParser jp = factory.createJsonParser(response.toString());
        this.response = mapper.readTree(jp);
    } catch (IOException ex) {
        logger.error("Failed to parse JSONObject", ex);
    }
}

From source file:uk.ac.soton.itinnovation.sad.service.domain.JsonResponse.java

public JsonResponse(String result, JSONArray response) {
    this.result = result;
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(Include.NON_NULL);
    JsonFactory factory = mapper.getJsonFactory();
    try {/*from   w w w .  java  2  s.  co  m*/
        JsonParser jp = factory.createJsonParser(response.toString());
        this.response = mapper.readTree(jp);
    } catch (IOException ex) {
        logger.error("Failed to parse JSONArray", ex);
    }
}

From source file:com.pursuer.reader.easyrss.data.parser.ItemJSONParser.java

public ItemJSONParser(final byte[] input) throws JsonParseException, IOException {
    final JsonFactory factory = new JsonFactory();
    this.parser = factory.createJsonParser(input);
}

From source file:com.pursuer.reader.easyrss.data.parser.ItemJSONParser.java

public ItemJSONParser(final InputStream input) throws JsonParseException, IOException {
    final JsonFactory factory = new JsonFactory();
    this.parser = factory.createJsonParser(input);
}

From source file:com.pursuer.reader.easyrss.data.parser.TagJSONParser.java

public void parse() throws JsonParseException, IOException, IllegalStateException {
    final JsonFactory factory = new JsonFactory();
    final JsonParser parser = factory.createJsonParser(input);
    Tag tag = new Tag();
    int level = 0;
    boolean found = false;
    while (parser.nextToken() != null) {
        final String name = parser.getCurrentName();
        switch (parser.getCurrentToken()) {
        case START_OBJECT:
        case START_ARRAY:
            level++;/*from   w  w  w  .ja v  a2 s .c  om*/
            break;
        case END_OBJECT:
        case END_ARRAY:
            level--;
            break;
        case VALUE_STRING:
            if (level == 3) {
                if ("id".equals(name)) {
                    tag.setUid(parser.getText());
                } else if ("sortid".equals(name)) {
                    tag.setSortId(parser.getText());
                }
            }
        case FIELD_NAME:
            if (level == 1 && "tags".equals(name)) {
                found = true;
            }
        default:
        }
        if (level == 2) {
            if (tag.getUid() != null && listener != null) {
                listener.onTagRetrieved(tag);
            }
            tag = new Tag();
        }
    }
    parser.close();
    if (!found) {
        throw new IllegalStateException("Invalid JSON input");
    }
}