Examples of JsonParser


Examples of org.apache.flink.streaming.connectors.json.JSONParser

  @Test
  public void testGetBooleanFunction() {
    String jsonText = "{\"key\":true}";
    String searchedField = "key";
    try {
      JSONParser parser = new JSONParser(jsonText);
      JSONObject jo = parser.parse(searchedField);

      assertTrue(jo.getBoolean("retValue"));
    }
    catch (JSONException e) {
      fail();
View Full Code Here

Examples of org.apache.jackrabbit.commons.json.JsonParser

        }

        Node parent = (Node) item;
        try {
            NodeHandler hndlr = new NodeHandler(parent, nodeName);           
            new JsonParser(hndlr).parse(diffValue);
        } catch (IOException e) {
            if (e instanceof DiffException) {
                throw (DiffException) e;
            } else {
                throw new DiffException(e.getMessage(), e);
View Full Code Here

Examples of org.apache.jackrabbit.commons.json.JsonParser

    }

    private Value extractValue(String diffValue) throws RepositoryException, DiffException, IOException {
        ValueHandler hndlr = new ValueHandler();
        // surround diff value { key : } to make it parsable
        new JsonParser(hndlr).parse("{\"a\":"+diffValue+"}");

        return hndlr.getValue();
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.json.JsonParser

    }

    private Value[] extractValues(String diffValue) throws RepositoryException, DiffException, IOException {
        ValuesHandler hndlr = new ValuesHandler();
        // surround diff value { key : } to make it parsable
        new JsonParser(hndlr).parse("{\"a\":"+diffValue+"}");
       
        return hndlr.getValues();
    }
View Full Code Here

Examples of org.apache.noggit.JSONParser

        String body = IOUtils.toString(reader);
        log.trace("body", body);
        reader = new StringReader(body);
      }

      parser = new JSONParser(reader);
      this.processUpdate();
    }
    finally {
      IOUtils.closeQuietly(reader);
    }
View Full Code Here

Examples of org.boon.json.JsonParser

            if (!optionAsValues) {
                throw new UnsupportedOperationException("Not supported!");
            }
            io.gatling.jsonpath.JsonPath jsonPath = JsonPath$.MODULE$.compile(path).right().get();

            JsonParser jsonParser = new JsonParserCharArray();
            Object jsonModel = jsonParser.parse(json);
            query = jsonPath.query(jsonModel);

        } catch (Exception e) {
            error = getError(e);
        } finally {
View Full Code Here

Examples of org.codehaus.jackson.JsonParser

      throws IOException {
 
      this.depth = depth;
      byte[] in = input.getBytes("UTF-8");
      JsonFactory f = new JsonFactory();
      JsonParser p = f.createJsonParser(
          new ByteArrayInputStream(input.getBytes("UTF-8")));
     
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      Encoder cos = new BlockingBinaryEncoder(os, bufferSize);
      serialize(cos, p, os);
View Full Code Here

Examples of org.codehaus.jackson.JsonParser

    private <T> T parseContent(InputStream content, String string) {
        Map<String, Object> map = Collections.emptyMap();

        try {
            // create parser manually to lower Jackson requirements
            JsonParser jsonParser = mapper.getJsonFactory().createJsonParser(content);
            try {
                map = mapper.readValue(jsonParser, Map.class);
            } finally {
                countStreamStats(content);
            }
View Full Code Here

Examples of org.codehaus.jackson.JsonParser

    @SuppressWarnings("rawtypes")
    private boolean retryFailedEntries(InputStream content, TrackingBytesArray data) {
        try {
            ObjectReader r = JsonFactory.objectReader(mapper, Map.class);
            JsonParser parser = mapper.getJsonFactory().createJsonParser(content);
            try {
                if (ParsingUtils.seek("items", new JacksonJsonParser(parser)) == null) {
                    // recorded bytes are ack here
                    stats.bytesAccepted += data.length();
                    stats.docsAccepted += data.entries();
View Full Code Here

Examples of org.codehaus.jackson.JsonParser

    public static int importSorted(String jsonFile, ColumnFamily columnFamily, String ssTablePath, IPartitioner<?> partitioner) throws IOException
    {
        int importedKeys = 0; // already imported keys count
        long start = System.currentTimeMillis();

        JsonParser parser = getParser(jsonFile);

        if (keyCountToImport == null)
        {
            keyCountToImport = 0;
            System.out.println("Counting keys to import, please wait... (NOTE: to skip this use -n <num_keys>)");

            parser.nextToken(); // START_OBJECT
            while (parser.nextToken() != null)
            {
                parser.nextToken();
                parser.skipChildren();
                if (parser.getCurrentName() == null) continue;

                keyCountToImport++;
            }
        }

        System.out.printf("Importing %s keys...%n", keyCountToImport);

        parser = getParser(jsonFile); // renewing parser
        SSTableWriter writer = new SSTableWriter(ssTablePath, keyCountToImport);

        int lineNumber = 1;
        DecoratedKey prevStoredKey = null;

        while (parser.nextToken() != null)
        {
            String key = parser.getCurrentName();

            if (key != null)
            {
                String tokenName = parser.nextToken().name();

                if (tokenName.equals("START_ARRAY"))
                {
                    if (columnFamily.getColumnFamilyType() == ColumnFamilyType.Super)
                    {
                        throw new RuntimeException("Can't write Standard columns to the Super Column Family.");
                    }

                    List<?> columns = parser.readValueAs(new TypeReference<List<?>>() {});
                    addToStandardCF(columns, columnFamily);
                }
                else if (tokenName.equals("START_OBJECT"))
                {
                    if (columnFamily.getColumnFamilyType() == ColumnFamilyType.Standard)
                    {
                        throw new RuntimeException("Can't write Super columns to the Standard Column Family.");
                    }

                    Map<?, ?> columns = parser.readValueAs(new TypeReference<Map<?, ?>>() {});
                    addToSuperCF(columns, columnFamily);
                }
                else
                {
                    throw new UnsupportedOperationException("Only Array or Hash allowed as row content.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.