Open jflute opened 2 years ago
For example. Gson ignore both side delimiters:
serialize: (fieldName to JSON name)
public void test_demo() {
FieldNamingPolicy policy = FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
Field field = DfReflectionUtil.getWholeField(Sea.class, "_firstName_");
log(policy.translateName(field)); // _first_name_ (different result with Srl)
}
public static class Sea {
public String _firstName_;
}
deserialize: (originally wide scope)
public void test_demo() {
String json = "{'_first_name_': 'mystic', '_second_name_': 'mystic', '_third_name_': 'mystic'}";
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
Sea sea = gson.fromJson(json, Sea.class);
log(sea._firstName_); // mystic
log(sea._second_name_); // mystic
log(sea._THIRD_NAME_); // null
}
public static class Sea {
public String _firstName_;
public String _second_name_;
public String _THIRD_NAME_;
}
for now: no problem?