Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper


    }

    private JsonNode buildTree_and_getRoot_fromContent(String jsonContent){
        JsonNode node = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            node = objectMapper.readTree(jsonContent);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        return node;
View Full Code Here


    }

    private JsonNode buildTree_and_getRoot_fromFile(File jsonFile){
        JsonNode node = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            String jsonContent = "";
            BufferedReader reader = new BufferedReader(new FileReader(jsonFile));
            String line;
            while((line = reader.readLine()) != null) jsonContent += line;
            reader.close();
            node = objectMapper.readTree(jsonContent);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        return node;
View Full Code Here

    protected Logger getLogger() {
        return LOG;
    }

    private VersionCheckResponse parse(String httpBody) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(httpBody, VersionCheckResponse.class);
    }
View Full Code Here

     */

    private static final Logger LOG = LoggerFactory.getLogger(Ping.class);

    public static void ping(AsyncHttpClient client, URI server, URI ourUri, String radioId) throws IOException, ExecutionException, InterruptedException {
        ObjectMapper mapper = new ObjectMapper();

        ObjectNode rootNode = mapper.createObjectNode();
        rootNode.put("rest_transport_address", ourUri.toString());

        final UriBuilder uriBuilder = UriBuilder.fromUri(server);
        uriBuilder.path("/system/radios/" + radioId + "/ping");

View Full Code Here

  ObjectMapper mapper;

  @Before
  public void setUp() {

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

     * @return the JSON byte array
     * @throws IOException
     */
    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

@javax.ws.rs.ext.Provider
public class ObjectMapperProvider implements Provider<ObjectMapper>, ContextResolver<ObjectMapper> {
    private final ObjectMapper objectMapper;

    public ObjectMapperProvider() {
        objectMapper = new ObjectMapper()
                .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
                .setPropertyNamingStrategy(new PreserveLeadingUnderscoreStrategy())
                .registerModule(new JodaModule())
                .registerModule(new GuavaModule())
                .registerModule(new SimpleModule().addSerializer(new RangeJsonSerializer()));
View Full Code Here

            final ExportBundleRequest exportBundleRequest = form.get();
            ConfigurationBundle bundle = bundleService.export(exportBundleRequest);

            response().setContentType(MediaType.JSON_UTF_8.toString());
            response().setHeader("Content-Disposition", "attachment; filename=content_pack.json");
            ObjectMapper m = new ObjectMapper();
            ObjectWriter ow = m.writer().withDefaultPrettyPrinter();
            return ok(ow.writeValueAsString(bundle));
        } catch (IOException e) {
            flash("error", "Could not reach Graylog2 server");
        } catch (Exception e) {
            flash("error", "Unexpected error exporting configuration bundle, please try again later");
View Full Code Here

    static ObjectMapper objectMapper;

    @BeforeClass
    public static void init() {
        objectMapper = new ObjectMapper();
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
    }
View Full Code Here

     * histogram boundaries.
     */
    public AbsoluteRange getHistogramBoundaries() {
        if (boundaries == null) {
            try {
                ObjectMapper mapper = new ObjectMapper();
                JsonParser jp = mapper.getFactory().createParser(getBuiltQuery());
                JsonNode rootNode = mapper.readTree(jp);
                JsonNode timestampNode = rootNode.findValue("range").findValue("timestamp");
                String from = Tools.elasticSearchTimeFormatToISO8601(timestampNode.findValue("from").asText());
                String to = Tools.elasticSearchTimeFormatToISO8601(timestampNode.findValue("to").asText());
                boundaries = new AbsoluteRange(from, to);
            } catch (Exception ignored) {}
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.