Fastjson version number: implementation ‘com. Alibaba: fastjson: 1.2.69’
Error message:
com.alibaba.fastjson.JSONException: default constructor not found
User.kt
data class User(var name: String, var age: Int) {
}
Problem analysis:
The results found on the Internet are that there are no parameter free construction methods for object classes, so add
user.kt
data class User(var name: String, var age: Int) {
constructor() : this("", 0)
}
However, the error is still reported. By understanding the fastjason source code, it turns out that it needs to get the kotlin construction method through reflection. To use kotlin reflection, it needs to rely on [kotlin reflect]:
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.5.20'
After the above dependencies are added, even if there is no parameter free construction method, it can be used normally through the test
Read More:
- The project uses fastjason to report an error
- Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
- After verifying parameters with validation, springboot reports an error: no constructor found in package name + class name
- Default constructor cannot handle exception type FileNotFoundException thrown by implicit super cons
- Vue project error: uncaught typeerror: vuex__ WEBPACK_ IMPORTED_ MODULE_ 1__ . default.store is not a constructor
- mongo Failed to instantiate *** constructor NO_CONSTRUCTOR with arguments
- [screen recording] an error is reported in the screenrecord command: inaccessible or not found
- The vscode installation plug-in liveserver specified browser reported an error and could not be found
- An error was reported in the process of importing the table from mysql5.7: [err] 1067 – invalid default value for ‘***‘
- The springboot integration mybatis reported an error. The parameter cannot be found
- An unable to locate appropriate constructor on class solution appears
- com.alibaba.fastjson .JSONException: For input string: “3000-01-01” or “9999-12-31”
- Error running app: Default Activity Not Found
- When Maven hits the jar package, an error is reported when executing install, and the symbol cannot be found in a line
- The typereference reported an error classnotfoundexception:
- Android studio reported an error in the release package: Lint found fatal errors while assembling a release target
- Ntpdate reported an error when updating the clock, and the problem of no server suitable for synchronization found was solved
- An error was reported when idea compiles Java: no symbol was found_ How to solve this problem
- The software licensing service reported that the product SKU is not found
- An error was reported on the command line of Vue when it first wrote a small project: expected indentation of 4 spaces but found 6