Code example for Gson

0
  private Gson gson;
 
  @Override 
  protected void setUp() throws Exception { 
    super.setUp(); 
    gson = new Gson();
  } 
 
  public void testPrimitiveCharacterAutoboxedSerialization() { 
    assertEquals("\"A\"", gson.toJson('A'));
    assertEquals("\"A\"", gson.toJson('A', char.class));
    assertEquals("\"A\"", gson.toJson('A', Character.class));
  } 
 
  public void testPrimitiveCharacterAutoboxedDeserialization() { 
    char expected = 'a';
    char actual = gson.fromJson("a", char.class);
    assertEquals(expected, actual);
 
    actual = gson.fromJson("\"a\"", char.class);
Connect your IDE to all the code out there  Get Codota for Java