Code example for Gson

0
  private Gson gson;
 
  @Override 
  protected void setUp() throws Exception { 
    super.setUp(); 
    gson = new Gson();
  } 
 
  public void testStringValueSerialization() throws Exception { 
    String value = "someRandomStringValue";
    assertEquals('"' + value + '"', gson.toJson(value));
  } 
 
  public void testStringValueDeserialization() throws Exception { 
    String value = "someRandomStringValue";
    String actual = gson.fromJson("\"" + value + "\"", String.class);
    assertEquals(value, actual);
  } 
 
  public void testSingleQuoteInStringSerialization() throws Exception {