Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper.reader()


  public NameServerInterface deserialize(JsonParser jsonParser,
      DeserializationContext deserializationContext) {
    ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
    ObjectNode objectNode;
    try {
      objectNode = (ObjectNode) mapper.reader()
          .without(DeserializationFeature.UNWRAP_ROOT_VALUE)
          .readTree(jsonParser);
    } catch (IOException e) {
      throw new DNSAPIClientJsonMappingException(
          DNSAPIClientJsonMappingExceptionCode.unexpectedMappingError,
View Full Code Here


    public static <T> T assertParseExampleFile(String fileName, Class<T> clazz) throws Exception {
        ObjectMapper mapper = KubernetesFactory.createObjectMapper();
        File exampleFile = new File(getKubernetesExamplesDir(), fileName);
        assertFileExists(exampleFile);
        T answer = mapper.reader(clazz).readValue(exampleFile);
        assertNotNull("Null returned while unmarshalling " + exampleFile, answer);
        System.out.println("Parsed: " + fileName + " as: " + answer);
        System.out.println();
        return answer;
    }
View Full Code Here

        builder.addFileConfiguration(fileName, json);

        if (oldData == null || oldData.length == 0) {
            return null;
        } else {
            return mapper.reader(ProjectRequirements.class).readValue(oldData);
        }
    }

    private synchronized Map<String, String> getAllServiceMixBundles() throws InterruptedException {
        doGetAllServiceMixBundles();
View Full Code Here

    public void saveBrokerConfigurationJSON(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
        List<MQBrokerConfigDTO> dtos = new ArrayList<MQBrokerConfigDTO>();
        MappingIterator<Object> iter = mapper.reader(MQBrokerConfigDTO.class).readValues(json);
        while (iter.hasNext()) {
            Object next = iter.next();
            if (next instanceof MQBrokerConfigDTO) {
                dtos.add((MQBrokerConfigDTO) next);
            } else {
View Full Code Here

    @Override
    public void requirementsJson(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
        Object value = mapper.reader(FabricRequirements.class).readValue(json);
        if (value instanceof FabricRequirements) {
            requirements((FabricRequirements) value);
        } else {
            throw new IOException("Failed to parse FabricRequirements from JSON. Got " + value + ". JSON: " + json);
        }
View Full Code Here

        CsvSchema schema = CsvSchema.builder()
            .addColumn("name")
            .addColumn("loc.x")
            .addColumn("loc.y")
            .build();
        Unwrapping wrapper = mapper.reader(schema).withType(Unwrapping.class).readValue(CSV);
        assertNotNull(wrapper);
        assertNotNull(wrapper.location);
        assertEquals(15, wrapper.location.x);
        assertEquals(27, wrapper.location.y);
View Full Code Here

            .addColumn("first")
            .addColumn("second")
            .build();

        @SuppressWarnings("resource")
        MappingIterator<Map<?,?>> it = mapper.reader(schema).withType(Map.class).readValues(
                "a,b\nc,d,\ne,f,  \nfoo,bar,x\n");
        assertTrue(it.hasNext());
       
        // first should have no problems anyway:
        Map<?,?> result = it.nextValue();
View Full Code Here

        assertValidJSON(json);
    }

    public static JsonNode assertValidJSON(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.reader().readTree(json);
    }


}
View Full Code Here

    public void testSimpleUnwrappingRoundtrip()
        throws Exception
    {
        final String XML = "<Unwrapping><name>Joe</name><loc.x>15</loc.x><loc.y>27</loc.y></Unwrapping>";
        ObjectMapper mapper = xmlMapper(false);
        Unwrapping wrapper = mapper.reader(Unwrapping.class).readValue(XML);
        assertNotNull(wrapper);
        assertNotNull(wrapper.location);
        assertEquals(15, wrapper.location.x);
        assertEquals(27, wrapper.location.y);
View Full Code Here

    public void testUnwrappingWithAttribute()
        throws Exception
    {
        final String XML = "<UnwrappingWithAttributes name=\"Joe\" loc.x=\"15\" loc.y=\"27\"/>";
        ObjectMapper mapper = xmlMapper(false);
        UnwrappingWithAttributes wrapper = mapper.reader(UnwrappingWithAttributes.class).readValue(XML);
        assertNotNull(wrapper);
        assertNotNull(wrapper.location);
        assertEquals(15, wrapper.location.x);
        assertEquals(27, wrapper.location.y);
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.