Search in sources :

Example 6 with MediaContent

use of data.media.MediaContent in project jvm-serializers by eishay.

the class StaxSerializer method writeDocument.

public void writeDocument(XMLStreamWriter writer, MediaContent[] items) throws XMLStreamException {
    writer.writeStartDocument("UTF-8", "1.0");
    writer.writeStartElement(XmlStax.STREAM_ROOT);
    for (MediaContent item : items) {
        writeMediaContent(writer, item);
    }
    writer.writeEndElement();
    writer.writeEndDocument();
}
Also used : MediaContent(data.media.MediaContent)

Example 7 with MediaContent

use of data.media.MediaContent in project fastjson by alibaba.

the class ListFieldTest3 method test_typeRef.

public void test_typeRef() throws Exception {
    String text = "{\"images\":[],\"media\":{\"width\":640}}";
    MediaContent object = JSON.parseObject(text, MediaContent.class);
}
Also used : MediaContent(data.media.MediaContent)

Example 8 with MediaContent

use of data.media.MediaContent in project fastjson by alibaba.

the class Case_Eishay method test_0.

public void test_0() throws Exception {
    //JavaBeanMapping.getGlobalInstance().setAsmEnable(false);
    System.out.println(text);
    MediaContent object = JSON.parseObject(text, MediaContent.class);
    String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
    System.out.println(text2);
    System.out.println(JSON.toJSONString(JSON.parseObject(text2), true));
}
Also used : MediaContent(data.media.MediaContent)

Example 9 with MediaContent

use of data.media.MediaContent in project jvm-serializers by eishay.

the class JBossMarshalling method register.

public static void register(final TestGroups groups) {
    MarshallerFactory riverFactory = new RiverMarshallerFactory();
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river", riverFactory, false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, "full graph zero knowledge"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-manual", riverFactory, false, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph with manual optimizations"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct", riverFactory, true, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.CLASSES_KNOWN, "full graph with preregistered classes"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct-manual", riverFactory, true, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph preregistered classes, manual optimization"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-serial", new SerialMarshallerFactory(), false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) MediaContent(data.media.MediaContent) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory)

Example 10 with MediaContent

use of data.media.MediaContent in project jvm-serializers by eishay.

the class JacksonAvroDatabind method register.

public static void register(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new AvroFactory());
    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
    JavaType type = mapper.constructType(MediaContent.class);
    AvroSchema schema = new AvroSchema(Avro.Media.sMediaContent);
    ObjectReader reader = mapper.readerFor(type).with(schema);
    ObjectWriter writer = mapper.writerFor(type).with(schema);
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("avro/jackson/databind", type, mapper, reader, writer), new SerFeatures(SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) AvroFactory(com.fasterxml.jackson.dataformat.avro.AvroFactory) AvroSchema(com.fasterxml.jackson.dataformat.avro.AvroSchema) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) MediaContent(data.media.MediaContent) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

MediaContent (data.media.MediaContent)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 SerFeatures (serializers.SerFeatures)4 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 Image (data.media.Image)3 Media (data.media.Media)2 ArrayList (java.util.ArrayList)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)1 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)1 SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)1 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JavaType (com.fasterxml.jackson.databind.JavaType)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 AvroFactory (com.fasterxml.jackson.dataformat.avro.AvroFactory)1 AvroSchema (com.fasterxml.jackson.dataformat.avro.AvroSchema)1 CBORFactory (com.fasterxml.jackson.dataformat.cbor.CBORFactory)1 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)1