Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonGenerator.writeObject()


          g.writeStartObject();
          g.writeFieldName("__cmds");
          g.writeStartArray();
          List<Object> functions = new ArrayList<Object>(context.getFunctions());
          for (Object function : functions) {
            g.writeObject(function);
          }
          g.writeEndArray();
          g.writeEndObject();
          g.close();
        }
View Full Code Here


    JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());

    StringWriter out = new StringWriter(1000);
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(out);
    if (pretty) jsonGenerator.useDefaultPrettyPrinter();
    jsonGenerator.writeObject(bean);
    out.flush();

    return out.toString();
  }
View Full Code Here

                            Object valueObject = valueSerializer.toObject((null == valueCompressionStrategy) ? valueBytes
                                                                                                            : valueCompressionStrategy.inflate(valueBytes));
                            if(keyObject instanceof GenericRecord) {
                                out.write(keyObject.toString());
                            } else {
                                generator.writeObject(keyObject);
                            }
                            out.write(' ' + version.toString() + ' ');
                            if(valueObject instanceof GenericRecord) {
                                out.write(valueObject.toString());
                            } else {
View Full Code Here

                            }
                            out.write(' ' + version.toString() + ' ');
                            if(valueObject instanceof GenericRecord) {
                                out.write(valueObject.toString());
                            } else {
                                generator.writeObject(valueObject);
                            }
                            out.write('\n');
                        }
                    }
                });
View Full Code Here

                                                                                                    : keysCompressionStrategy.inflate(keyBytes));

                            if(keyObject instanceof GenericRecord) {
                                out.write(keyObject.toString());
                            } else {
                                generator.writeObject(keyObject);
                            }
                            out.write('\n');
                        }
                    }
                });
View Full Code Here

                                                                                                        : keysCompressionStrategy.inflate(keyBytes));

                                if(keyObject instanceof GenericRecord) {
                                    out.write(keyObject.toString());
                                } else {
                                    generator.writeObject(keyObject);
                                }
                                out.write('\n');
                            }
                        }
                    });
View Full Code Here

                                Object valueObject = valueSerializer.toObject((null == valueCompressionStrategy) ? valueBytes
                                                                                                                : valueCompressionStrategy.inflate(valueBytes));
                                if(keyObject instanceof GenericRecord) {
                                    out.write(keyObject.toString());
                                } else {
                                    generator.writeObject(keyObject);
                                }
                                out.write(' ' + version.toString() + ' ');
                                if(valueObject instanceof GenericRecord) {
                                    out.write(valueObject.toString());
                                } else {
View Full Code Here

                                }
                                out.write(' ' + version.toString() + ' ');
                                if(valueObject instanceof GenericRecord) {
                                    out.write(valueObject.toString());
                                } else {
                                    generator.writeObject(valueObject);
                                }
                                out.write('\n');
                            }
                        }
                    });
View Full Code Here

                for (final DateTime timestamp : timestamps) {
                    final Object dataPoint = samplesForType.get(timestamp);
                    // Might have been evicted already
                    if (dataPoint != null) {
                        generator.writeNumber(unixSeconds(timestamp));
                        generator.writeObject(dataPoint);
                    }
                }
            }

            generator.writeEndArray();
View Full Code Here

    public String marshall(T obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            StringWriter output = new StringWriter();
            JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(output);
            jsonGenerator.writeObject(obj);
            return output.toString();
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
    }
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.