Code example for Gson

Methods: toJson

0
    assertEquals(expected, actual);
  } 
 
  public void testStringsWithUnicodeChineseCharactersSerialization() throws Exception { 
    String target = "\u597d\u597d\u597d";
    String json = gson.toJson(target);
    String expected = "\"\u597d\u597d\u597d\"";
    assertEquals(expected, json);
  } 
 
  public void testStringsWithUnicodeChineseCharactersDeserialization() throws Exception { 
    String expected = "\u597d\u597d\u597d";
    String json = "\"" + expected + "\"";
    String actual = gson.fromJson(json, String.class);
    assertEquals(expected, actual);
  } 
 
  public void testStringsWithUnicodeChineseCharactersEscapedDeserialization() throws Exception { 
    String actual = gson.fromJson("'\\u597d\\u597d\\u597d'", String.class);
    assertEquals("\u597d\u597d\u597d", actual);
Experience pair programming with AI  Get Codota for Java