예제 #1
0
    public void toJson(JsonGenerator gen) throws IOException {
      gen.writeStartObject();

      gen.writeBooleanField("old", oldRecordExists);
      gen.writeBooleanField("new", newRecordExists);
      gen.writeBooleanField("includeSubscriptions", includeSubscriptions);

      if (newRecordType != null) {
        gen.writeBinaryField("newRecordType", newRecordType.getBytes());
      }

      if (oldRecordType != null) {
        gen.writeBinaryField("oldRecordType", oldRecordType.getBytes());
      }

      if (fieldChanges != null) {
        gen.writeArrayFieldStart("fields");

        for (FieldChange fieldChange : fieldChanges) {
          fieldChange.toJson(gen);
        }

        gen.writeEndArray();
      }

      if (indexSubscriptionIds != null) {
        gen.writeArrayFieldStart("subscriptions");
        for (String subscriptionId : indexSubscriptionIds) {
          gen.writeString(subscriptionId);
        }
        gen.writeEndArray();
      }

      gen.writeEndObject();
    }
예제 #2
0
    public void toJson(JsonGenerator gen) throws IOException {
      gen.writeStartObject();

      gen.writeBinaryField("id", id.getBytes());

      if (oldValue != null) {
        gen.writeBinaryField("old", oldValue);
      }

      if (newValue != null) {
        gen.writeBinaryField("new", newValue);
      }

      gen.writeEndObject();
    }
 @Override
 public void serialize(Producto producto, JsonGenerator jsonGenerator, SerializerProvider sp)
     throws IOException, org.codehaus.jackson.JsonProcessingException {
   jsonGenerator.writeStartObject();
   jsonGenerator.writeNumberField("idproducto", producto.getIdproducto());
   jsonGenerator.writeStringField("nombre", producto.getNombreProducto());
   if (producto.getImagen() != null) {
     jsonGenerator.writeBinaryField("imagen", producto.getImagen());
   }
   jsonGenerator.writeStringField(
       "categoria", producto.getCategoriaIdCategoria().getNombreCategoria());
   jsonGenerator.writeEndObject();
 }