@Override protected JsonParserAndMapper initialValue() { return new JsonParserFactory().create(); } };
public BoonMapper() { mapper = new ObjectMapperImpl( new JsonParserFactory().lax(), new JsonSerializerFactory()); }
public JsonParserAndMapper parser () { jsonCharSrcParser = new JsonParserFactory( ).createCharacterSourceParser(); return jsonCharSrcParser; }
@Override public JsonParserAndMapper parser() { return parserFactory.create(); }
JsonParserFactory jsonParserFactory = new JsonParserFactory() .useFieldsFirst().useFieldsOnly().usePropertiesFirst().usePropertyOnly() //one of these .lax() //allow loose parsing of JSON like JSON Smart .strict() //opposite of lax .setCharset( StandardCharsets.UTF_8 ) //Set the standard charset, defaults to UTF_8 .setChop( true ) //chops up buffer overlay buffer (more discussion of this later) .setLazyChop( true ) //similar to chop but only does it after map.get final JsonParserAndMapper jsonParserAndMapper = jsonParserFactory.create(); final JsonSerializer jsonSerializer = jsonSerializerFactory.create();
public static <T> T createFromJsonMap(Class<T> type, String str) { Map<String,Object> config = new JsonParserFactory().createLaxParser().parseMap( str ); return Creator.create( type, config ); }
public ObjectMapperImpl () { this.parserFactory = new JsonParserFactory(); this.serializerFactory = new JsonSerializerFactory(); this.serializerFactory.useFieldsOnly(); }
public JsonParserAndMapper parser () { return new JsonParserFactory().setLazyChop( true ).create(); }
public static ObjectMapper createUseProperties (boolean useJsonDates) { JsonParserFactory jpf = new JsonParserFactory(); jpf.usePropertiesFirst(); JsonSerializerFactory jsf = new JsonSerializerFactory(); jsf.usePropertiesFirst(); if (useJsonDates) { jsf.useJsonFormatForDates(); } return new ObjectMapperImpl(jpf, jsf); }
@Test public void testForBug202_3() { String test = "{ \n" + " \"timestamp\":1405673028,\n" + " \"status\":200,\n" + " \"request\":{ \n" + " \"mbean\":\"com.openexchange.pooling:name=ConfigDB Read\",\n" + " \"attribute\":\"MaxUseTime\",\n" + " \"type\":\"read\"\n" + " },\n" + " \"value\":24\n" + "}"; final JsonParserFactory jsonParserFactory = new JsonParserFactory(); final Map<String, Object> stringObjectMap = jsonParserFactory.createFastParser().parseMap(test); }
public JsonParserAndMapper parser () { return new JsonParserFactory().setLazyChop( true ).createFastParser(); }
public JsonParserAndMapper parser () { return new JsonParserFactory().setLazyChop( true ).createLaxParser(); }
@Test public void testWithMapUsingFactory() { JsonParserFactory jsonParserFactory = new JsonParserFactory() .useFieldsFirst() .lax() //allow loose parsing of JSON like JSON Smart .setCharset( StandardCharsets.UTF_8 ) //Set the standard charset, defaults to UTF_8 .setLazyChop( true ) //similar to chop but only does it after map.get ; JsonSerializerFactory jsonSerializerFactory = new JsonSerializerFactory() .useFieldsFirst() //one of these //.addPropertySerializer( ) customize property output //.addTypeSerializer( ) customize type output .useJsonFormatForDates() //use json dates //.addFilter( ) add a property filter to exclude properties .includeEmpty().includeNulls().includeDefaultValues() //override defaults .handleComplexBackReference() //uses identity map to track complex back reference and avoid them .setHandleSimpleBackReference( true ) //looks for simple back reference for parent .setCacheInstances( true ) //turns on caching for immutable objects ; final ObjectMapper objectMapper = JsonFactory.create(jsonParserFactory, jsonSerializerFactory); MyClass myClass = new MyClass(); final String json = objectMapper.toJson(myClass); puts(json); final MyClass myClass1 = objectMapper.readValue(json, MyClass.class); assertEquals("foo", myClass1.string); assertEquals(1, myClass1.integer); assertNull(myClass1.map); }
@Before public void setUp() throws Exception { objectMapper = new ObjectMapperImpl(new JsonParserFactory().usePropertiesFirst().caseInsensitiveFields(), new JsonSerializerFactory().usePropertiesFirst()); }
@Parameterized.Parameters public static Collection<Object[]> data() { Object[][] data = new Object[][]{ {new ObjectMapperImpl(new JsonParserFactory().usePropertyOnly().acceptSingleValueAsArray(), new JsonSerializerFactory().usePropertyOnly())}, {new ObjectMapperImpl(new JsonParserFactory().useFieldsOnly().acceptSingleValueAsArray(), new JsonSerializerFactory().useFieldsOnly())} }; return Arrays.asList(data); }
public void test3() { user = new User("red", "yellow", "green", "purple"); puts(user.getFavoriteColors()); final JsonParserFactory jsonParserFactory = new JsonParserFactory().usePropertiesFirst().useAnnotations(); final JsonSerializerFactory serializerFactory = new JsonSerializerFactory().includeNulls().useAnnotations(); final ObjectMapper objectMapper = new ObjectMapperImpl(jsonParserFactory, serializerFactory); json = objectMapper.toJson(user); puts(json); user2 = objectMapper.fromJson(json, User.class); puts(user.getFavoriteColors()); ok = user.equals(user2) || die("Users should be equal", user, user2); }
public JsonParserAndMapper parser () { return new JsonParserFactory().createJsonCharArrayParser(); }
@Before public void setUp() throws Exception { objectMapper = new ObjectMapperImpl(new JsonParserFactory().usePropertyOnly().caseInsensitiveFields(), new JsonSerializerFactory().usePropertyOnly()); }
@Before public void setUp() throws Exception { objectMapper = new ObjectMapperImpl(new JsonParserFactory().useFieldsFirst().caseInsensitiveFields(), new JsonSerializerFactory().useFieldsFirst()); }
@Before public void setUp() throws Exception { objectMapper = new ObjectMapperImpl(new JsonParserFactory().useFieldsOnly().caseInsensitiveFields(), new JsonSerializerFactory().useFieldsOnly()); }