Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writer()


      exceptionDto.setType(InvalidRequestException.class.getSimpleName());
      exceptionDto.setMessage("Process engine " + engineName + " not available");
      ObjectMapper objectMapper = new ObjectMapper();

      resp.setContentType(MediaType.APPLICATION_JSON);
      objectMapper.writer().writeValue(resp.getWriter(), exceptionDto);
      resp.getWriter().flush();

      return;
    }
View Full Code Here


  {
    ObjectMapper mapper = new ObjectMapper();
    boolean pretty = request.getParams().getProperty("pretty") != null;
   
    // create pretty or regular writer
    ObjectWriter writer = pretty ? mapper.defaultPrettyPrintingWriter() : mapper.writer();
    StringWriter out = new StringWriter(10240);
   
    DbusEventBufferMult multBuf = _relay.getEventBuffer();
    Set<PhysicalPartitionKey> keys = multBuf.getAllPhysicalPartitionKeys();
    // creat map to output partId=>PhysicalSources...
View Full Code Here

        builder.append(line);
      }
      in.close();
      ObjectMapper mapper = new ObjectMapper();
      JsonNode json = mapper.readTree(builder.toString());
      return mapper.writer().writeValueAsString(json);
    }

    private static void writeFile(File f, String s) throws IOException {
      FileWriter w = new FileWriter(f);
      w.write(s);
View Full Code Here

      for (int i = 0; i < fields.size(); i++) {
        targetedFieldNames[i] = fields.get(i).getName();
      }

      filters.addFilter("PropertyFilter", SimpleBeanPropertyFilter.filterOutAllExcept(targetedFieldNames));
      ObjectWriter objectWriter = objectMapper.writer(filters);
      String json = objectWriter.writeValueAsString(entity);

      List<java.lang.reflect.Field> referencedEntities = ClassUtil.getAnnotatedFields(entity, Reference.class);
      for (java.lang.reflect.Field field : referencedEntities) {
        Cascade[] cascades = ClassUtil.getFieldAnnotationValue("cascade", field, Reference.class, Cascade[].class);
View Full Code Here

    public void testAnyGetterFiltering() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        FilterProvider prov = new SimpleFilterProvider().addFilter("anyFilter",
                SimpleBeanPropertyFilter.filterOutAllExcept("b"));
        assertEquals("{\"a\":\"1\"}", mapper.writer(prov).writeValueAsString(new AnyBean()));
    }
}
View Full Code Here

    public void testMapperVersions()
    {
        if (runsFromAnt()) {
            ObjectMapper mapper = new ObjectMapper();
            assertVersion(mapper.version(), MAJOR_VERSION, MINOR_VERSION);
            assertVersion(mapper.writer().version(), MAJOR_VERSION, MINOR_VERSION);
            assertVersion(mapper.reader().version(), MAJOR_VERSION, MINOR_VERSION);
        }
    }

    public void testXcVersions()
View Full Code Here

            ObjectNode      node = mapper.createObjectNode();
            node.put("name", name);
            arrayNode.add(node);
        }

        mapper.writer().writeValue(entityStream, arrayNode);
    }

    private static boolean allow(Class<?> type, MediaType mediaType)
    {
        return ServiceNames.class.isAssignableFrom(type) && mediaType.equals(MediaType.APPLICATION_JSON_TYPE);
View Full Code Here

    @Override
    public void writeTo(ServiceInstance<T> serviceInstance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException
    {
        ObjectMapper    mapper = new ObjectMapper();
        ObjectNode      node = writeInstance(mapper, serviceInstance, context);
        mapper.writer().writeValue(entityStream, node);
    }
}
View Full Code Here

        for ( ServiceInstance<T> instance : instanceList )
        {
            ObjectNode node = JsonServiceInstanceMarshaller.writeInstance(mapper, instance, context);
            arrayNode.add(node);
        }
        mapper.writer().writeValue(entityStream, arrayNode);
    }
}
View Full Code Here

      try {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(SerializationConfig.Feature.SORT_PROPERTIES_ALPHABETICALLY, true);
        ObjectWriter writer = this.formattedOutput
          ? mapper.writerWithDefaultPrettyPrinter()
          : mapper.writer();
         
        return writer.writeValueAsString(obj);
      } catch (Exception ex) {
        throw new JuRuntimeException("Marshalling of object to JSON failed", ex);
      }
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.