Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper


    assertEquals("time_id", column.name);
  }

  /** Reads a simple schema containing JdbcSchema, a sub-type of Schema. */
  @Test public void testSubtype() throws IOException {
    final ObjectMapper mapper = mapper();
    JsonRoot root = mapper.readValue(
        "{\n"
        + "  version: '1.0',\n"
        + "   schemas: [\n"
        + "     {\n"
        + "       type: 'jdbc',\n"
View Full Code Here


    assertEquals("FoodMart", schema.name);
  }

  /** Reads a custom schema. */
  @Test public void testCustomSchema() throws IOException {
    final ObjectMapper mapper = mapper();
    JsonRoot root = mapper.readValue(
        "{\n"
        + "  version: '1.0',\n"
        + "   schemas: [\n"
        + "     {\n"
        + "       type: 'custom',\n"
View Full Code Here

    this.schema = schema;
  }

  public RelNode read(String s) throws IOException {
    lastRel = null;
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
    Map<String, Object> o = mapper.readValue(s, TYPE_REF);
    readRels((List<Map<String, Object>>) o.get("rels"));
    System.out.println(lastRel);
    return lastRel;
  }
View Full Code Here

        final boolean showSamples = Boolean.parseBoolean(context.getInitParameter(SHOW_SAMPLES));
        MetricFilter filter = (MetricFilter) context.getAttribute(METRIC_FILTER);
        if (filter == null) {
          filter = MetricFilter.ALL;
        }
        this.mapper = new ObjectMapper().registerModule(new MetricsModule(rateUnit,
                                                                          durationUnit,
                                                                          showSamples,
                                                                          filter));

        this.allowedOrigin = context.getInitParameter(ALLOWED_ORIGIN);
View Full Code Here

        final Object executorAttr = config.getServletContext().getAttribute(HEALTH_CHECK_EXECUTOR);
        if (executorAttr instanceof ExecutorService) {
            this.executorService = (ExecutorService) executorAttr;
        }

        this.mapper = new ObjectMapper().registerModule(new HealthCheckModule());
    }
View Full Code Here

                                   "\"p98\":9.0," +
                                   "\"p99\":10.0," +
                                   "\"p999\":11.0," +
                                   "\"stddev\":5.0}");

        final ObjectMapper fullMapper = new ObjectMapper().registerModule(
                new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, true, MetricFilter.ALL));

        assertThat(fullMapper.writeValueAsString(histogram))
                .isEqualTo("{" +
                                   "\"count\":1," +
                                   "\"max\":2," +
                                   "\"mean\":3.0," +
                                   "\"min\":4," +
View Full Code Here

                                   "\"m5_rate\":4.0," +
                                   "\"mean_rate\":2.0," +
                                   "\"duration_units\":\"milliseconds\"," +
                                   "\"rate_units\":\"calls/second\"}");

        final ObjectMapper fullMapper = new ObjectMapper().registerModule(
                new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, true, MetricFilter.ALL));

        assertThat(fullMapper.writeValueAsString(timer))
                .isEqualTo("{" +
                                   "\"count\":1," +
                                   "\"max\":100.0," +
                                   "\"mean\":200.0," +
                                   "\"min\":300.0," +
View Full Code Here

    public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));

    private static final String CHARACTER = "a";

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }
View Full Code Here

        fromBuf = UTF_8.newDecoder().decode(backToBuf).toString();
        assertEquals(actualJson, fromBuf);
      } catch (CharacterCodingException e1) {
        throw new RuntimeException("Could not decode the string", e1);
      }
      ObjectMapper mapper = new ObjectMapper();
      try {
        assertTrue(mapper.readTree(expected).equals(mapper.readTree(actualJson)));
      } catch (IOException e) {
        fail("Exception while serializing. Expected " + expected);
      }
    }
View Full Code Here

        try {
            final InputStream configStream = configSource.getInputStream();
            buffer = toByteArray(configStream);
            configStream.close();
            final InputStream is = new ByteArrayInputStream(buffer);
            final ObjectMapper mapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true);
            root = mapper.readTree(is);
            if (root.size() == 1) {
                final Iterator<JsonNode> i = root.elements();
                root = i.next();
            }
            processAttributes(rootNode, root);
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.ObjectMapper

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.