Exemplo n.º 1
0
 public String serializeMap(Map<String, T> translator) throws IOException {
   StringWriter stringWriter = new StringWriter();
   JsonGenerator generator = Acela.JSON_FACTORY.createGenerator(stringWriter);
   serializeMap(generator, translator);
   generator.close();
   return stringWriter.toString();
 }
Exemplo n.º 2
0
  @Test
  public void testListParse() throws IOException {

    StringWriter stringWriter = new StringWriter();
    JsonGenerator jsonGenerator = Acela.JSON_FACTORY.createGenerator(stringWriter);

    TestingUtils.writeTestArray(jsonGenerator, null);

    jsonGenerator.close();

    List<SimpleObject> simpleObjects =
        Acela.getTranslator(SimpleObject.class).parseList(stringWriter.toString());
    assertNotNull(simpleObjects);
    assertEquals(2, simpleObjects.size());

    String generatedString = Acela.getTranslator(SimpleObject.class).serializeList(simpleObjects);
    String jsonString = stringWriter.toString();
    assertEquals(jsonString, generatedString);
  }