Solution:
1. If your project is a multi-module and distributed deployment, consider using the setup System.property
2. Generally only a very small number of code this situation, it is recommended that directly in your singleton service initialization, in the static block directly change the value of the typeutils variable, if you use spring can be used Initializingbean processing
Typeutils.compatiblewithjavabean = true;
3. This variable is public note to make changes in one place to avoid thread safety issues
The project group uses Fastjson, which occurs when the following JSON is output, expecting it to be uppercase but Fastjson to turn the value auto-first letter to lowercase
{"Code": 0, "message": "", "result": {"facts": {"IP": {"acun_one_min": 0, "Acun_ten_min": 0}}, "Level": 0}}
after the query found Fastjson internal bean conversion will be used to com.alibaba.fastjson.util.TypeUtils, the core code as follows, when the class is loaded to read the environment variables Fastjson.compatiblewithjavabean, if not found, the default value of FALSE will cause the first letter lowercase
Public Static BooleanCompatiblewithjavabean =false; Static { Try{String prop= System.getproperty ("Fastjson.compatiblewithjavabean"); if("True". Equals (prop)) {Compatiblewithjavabean=true; } Else if("false". Equals (prop)) {Compatiblewithjavabean=false; } } Catch(Throwable ex) {//Skip} }
public static list<fieldinfo> Computegetters (class<?> clazz, map<string, String> AliasMap, Boolean Sorted) {
String PropertyName;
if (Character.isuppercase (C3)) {
if (compatiblewithjavabean) {
PropertyName = Introspector.decapitalize (methodname.substring (3));
} else {
PropertyName = Character.tolowercase (Methodname.charat (3)) + methodname.substring (4);
}
} else if (C3 = = ' _ ') {
PropertyName = Methodname.substring (4);
} else if (C3 = = ' F ') {
PropertyName = Methodname.substring (3);
} else {
Continue
}}
Fastjson output value First letter case problem