Package com.stanfy.gsonxml

Examples of com.stanfy.gsonxml.GsonXml.fromXml()


    GsonXml gsonXml = new GsonXmlBuilder()
        .setSameNameLists(true)
        .setXmlParserCreator(parserCreator)
        .create();

    A a = gsonXml.fromXml("<A><B value=\"23.5\" /><C>Test</C></A>", A.class);
    assertEquals("{\"B\":[{\"@value\":23.5}],\"C\":[{\"$\":\"Test\"}]}", gsonXml.getGson().toJson(a));
  }

}
View Full Code Here


    GsonXml gsonXml = new GsonXmlBuilder()
        .setSameNameLists(true)
        .setXmlParserCreator(parserCreator)
        .create();

    A a = gsonXml.fromXml("<A><B /></A>", A.class);
    assertEquals("{\"B\":[{}]}", gsonXml.getGson().toJson(a));
  }


}
View Full Code Here


  @Test
  public void shouldHandleNestedSameNameLists() {
    GsonXml gsonXml = new GsonXmlBuilder().setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR).setSameNameLists(true).create();
    One res = gsonXml.fromXml(TEST_XML_NESTED_SAME_NAME_LIST, One.class);
    assertThat(res).isNotNull();
    assertThat(res.date).isEqualTo(1);

    assertThat(res.twos).isNotEmpty();
    assertThat(res.twos.size()).isEqualTo(1);
View Full Code Here

  }

  @Test
  public void shouldHandlePrimitiveNestedSameNameLists() {
    GsonXml gsonXml = new GsonXmlBuilder().setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR).setPrimitiveArrays(true).setSameNameLists(true).create();
    OnePrimitive res = gsonXml.fromXml(TEST_XML_NESTED_PRIMITIVE_SAME_NAME_LIST, OnePrimitive.class);
    assertThat(res).isNotNull();
    assertThat(res.date).isEqualTo(2);

    assertThat(res.twos).isNotEmpty();
    assertThat(res.twos.size()).isEqualTo(2);
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.