public BoonJsonObjectMapper() { this.objectMapper = JsonFactory.create(); }
public BoonJsonObjectMapper(JsonParserFactory parserFactory, JsonSerializerFactory serializerFactory) { this.objectMapper = JsonFactory.create(parserFactory, serializerFactory); }
public BoonJsonObjectMapper(JsonParserFactory parserFactory, JsonSerializerFactory serializerFactory) { this.objectMapper = JsonFactory.create(parserFactory, serializerFactory); }
public DZoneReadPojoBoon() { mapper = JsonFactory.create(); }
public DZoneWriteBoon() { mapper = JsonFactory.create(); }
public BoonJsonObjectMapper() { this.objectMapper = JsonFactory.create(); }
/** * Parse a text representation of a JSON data structure * * @param text JSON text to parse * @return a data structure of lists and maps */ public Object parseText(String text) { if (text == null || text.length() == 0) { throw new IllegalArgumentException("The JSON input text should neither be null nor empty."); } return JsonFactory.create().fromJson ( text ); }
/** * Parse a text representation of a JSON data structure * * @param text JSON text to parse * @return a data structure of lists and maps */ public Object parseText(String text) { if (text == null || text.length() == 0) { throw new IllegalArgumentException("The JSON input text should neither be null nor empty."); } return JsonFactory.create().fromJson ( text ); }
/** * Parse a text representation of a JSON data structure * * @param text JSON text to parse * @return a data structure of lists and maps */ public Object parseText(String text) { if (text == null || text.length() == 0) { throw new IllegalArgumentException("The JSON input text should neither be null nor empty."); } return JsonFactory.create().fromJson ( text ); }
public Map<String, Object> asJson() { return JsonFactory.create().readValue(this.content, Map.class); } }
public RequestHandler(Class<?> controllerClass, String controllerMethod, Injector injector) { this.injector = injector; this.controllerClass = controllerClass; this.controllerMethod = controllerMethod; this.controller = this.injector.getInstance(this.controllerClass); this.methodParameters = getMethodParameters(); this.parameterCount = this.methodParameters.size(); this.config = this.injector.getInstance(Config.class); this.globalFilter = this.injector.getAllBindings().containsKey(com.google.inject.Key.get(MangooGlobalFilter.class)); this.mapper = JsonFactory.create(); }
@Test public void testForBug202_2() { 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" + "}"; Map map = (Map) JsonFactory.create().fromJson(test); }
@Test public void testForBug202_1() { 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" + "}"; Map map = (Map) JsonFactory.create().fromJson(test); }
@Test public void test198() { Data original = new Data(Integer.MAX_VALUE, Long.MAX_VALUE); System.out.println("original: \n" + original + "\n"); ObjectMapper boon = JsonFactory.create(); String serialized = boon.writeValueAsString(original); System.out.println("serialized: \n" + serialized + "\n"); Data deserialized = boon.readValue(serialized, Data.class); System.out.println("deserialized: \n" + deserialized + "\n"); String reserialized = boon.writeValueAsString(deserialized); System.out.println("reserialized: \n" + reserialized + "\n"); }
@Test public void test() { ObjectMapper mapper = JsonFactory.create(new JsonParserFactory(), new JsonSerializerFactory().setSerializeMapKeys(true).setEncodeStrings(true)); HashMap<String, Object> data = new HashMap<>(); data.put("\"hi\"", Double.parseDouble("1.2312312")); assertEquals("{\"\\\"hi\\\"\":1.2312312}", mapper.toJson(data)); }
@Test public void serializingClassFieldCausesSegFault() { SomeClass someClassInstance = new SomeClass(Bug287.class); ObjectMapper mapper = JsonFactory.create(); final String json = mapper.toJson(someClassInstance); puts(json); SomeClass someClassInstance2 = mapper.readValue("{\"clazz\":\"org.boon.bugs.Bug287\"} ", SomeClass.class); ok = someClassInstance2.clazz.getName().equals("org.boon.bugs.Bug287"); }
public static void main(String... args) throws Exception{ Player kevin = new Player("Kevin", "Cricket", 32, 221, new int[]{33, 66, 78, 21, 9, 200}); final ObjectMapper mapper = JsonFactory.create(); final File file = File.createTempFile("json", "exmaple.json"); mapper.writeValue(file, kevin); Player somePlayer = mapper.readValue(file, Player.class); puts("They are equal", somePlayer.equals(kevin)); }
public static void part8WorkingWithPrimitives() throws Exception { puts ("\n\n\n\npart8WorkingWithPrimitives"); ObjectMapper mapper = JsonFactory.create(); String intStr = "123456"; int someNumber = mapper.parser().parseInt( intStr ); boolean ok = someNumber == 123456 || die( "" + someNumber ); String jsonArray = "[0,1,2,3,4,5,6,7,8]"; int [] intArray = mapper.parser().parseIntArray( jsonArray ); ok |= Arrays.equals( new int[]{1,2,3,4,5,6,7,8}, intArray ); String jsonMap = "{\"race\":true, \"speedup\": false, \"name\": \"bob\", \"value\": -0}"; Map <String, Object> map = mapper.parser().parseMap( jsonMap ); ok |= ( map.get("race") == Boolean.TRUE && map.get("name").equals( "bob" ) ) || die(map.toString()); ok |= (int)map.get("value") == -0 || die(map.get("value")); puts("ok?", ok); }
@Test public void test() { JsonSerializerFactory factory = new JsonSerializerFactory(); factory.usePropertyOnly(); ObjectMapper mapper = JsonFactory.create(null, factory); User user = new User(); EnumMap<Gender,User> map = new EnumMap<Gender, User>(Gender.class); map.put(Gender.FEMALE, user); puts(map); puts(mapper.writeValueAsString( map)); } }
public static void part3_1() throws Exception { ObjectMapper mapper = JsonFactory.create(); puts( mapper.writeValueAsString( user ) ); User user2 = mapper.readValue( mapper.writeValueAsString( user ), User.class ); puts( user2 ); boolean ok = user.equals ( user2 ) || die (user.toString ()); }