Examples of JsonOrgModule


Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

public class SimpleReadTest extends TestBase
{
    public void testReadObject() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());

        JSONObject ob = mapper.readValue("{\"a\":{\"b\":3}, \"c\":[9, -4], \"d\":null, \"e\":true}",
                JSONObject.class);
        assertEquals(4, ob.length());
        JSONObject ob2 = ob.getJSONObject("a");
View Full Code Here

Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

    }

    public void testReadArray() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());

        JSONArray array = mapper.readValue("[null, 13, false, 1.25, \"abc\", {\"a\":13}, [ ] ]",
                JSONArray.class);
        assertEquals(7, array.length());
        assertTrue(array.isNull(0));
View Full Code Here

Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

    }
   
    public void testWrappedArray() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());
        mapper.enableDefaultTyping();
        JSONTokener tok = new JSONTokener("[13]");
        JSONArray array = (JSONArray) tok.nextValue();

        String json = mapper.writeValueAsString(new ObjectWrapper(array));
View Full Code Here

Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

    }

    public void testWrappedObject() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());
        mapper.enableDefaultTyping();
        JSONTokener tok = new JSONTokener("{\"a\":true}");
        JSONObject array = (JSONObject) tok.nextValue();

        String json = mapper.writeValueAsString(new ObjectWrapper(array));
View Full Code Here

Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

public class SimpleWriteTest extends TestBase
{
    public void testWriteObject() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());

        // Ok: let's create JSONObject from JSON text
        String JSON = "{\"a\":{\"b\":3}}";
        JSONTokener tok = new JSONTokener(JSON);
        JSONObject ob = (JSONObject) tok.nextValue();
View Full Code Here

Examples of com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule

    }

    public void testWriteArray() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JsonOrgModule());

        // Ok: let's create JSONObject from JSON text
        String JSON = "[1,true,\"text\",[null,3],{\"a\":[1.25]}]";
        JSONTokener tok = new JSONTokener(JSON);
        JSONArray ob = (JSONArray) tok.nextValue();
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonorg.JsonOrgModule

    public TestJsonPerf(File f) throws IOException
    {
        _jsonFactory = new JsonFactory();
        _mapper = new ObjectMapper(_jsonFactory);
        _mapper.registerModule(new JsonOrgModule());
       
        _smileFactory = new SmileFactory();
        _smileMapper = new ObjectMapper(_smileFactory);
        _jsonData = readData(f);
        _jsonString = new String(_jsonData, "UTF-8");
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonorg.JsonOrgModule

                            deserializerFactory.withAdditionalDeserializers(deserializers);
                            serializerFactory.addGenericMapping(a.type(), serializer);
                            StdDeserializerProvider deserializerProvider =
                                new StdDeserializerProvider(deserializerFactory);
                            mapper = new ObjectMapper();
                            mapper.registerModule(new JsonOrgModule());

                            mapper.setSerializerFactory(serializerFactory);
                            mapper.setDeserializerProvider(deserializerProvider);
                        }
                    }
                }
            }
        }
        if ( cls != null && mapper == null ) {
            return MAPPER;
        }
        if (mapper == null) {
            mapper = new ObjectMapper();
            mapper.registerModule(new JsonOrgModule());
        }
        // Let's honor the Jackson annotations first
        AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
        AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
        AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
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.