osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

Data mapper - use `JSONObject` in case target type is not determined. #191

Closed greenlaw110 closed 5 years ago

greenlaw110 commented 5 years ago

At the moment it uses the source object type when it tried to copy a bean to an object. The issue is when there are fields in the source type get initialised with default value, while the source bean doesn't have any value on the fields, then it will generate a bean with combination of source value plus default value which is not defined in source bean. This is a side effect which we don't have specifically when we haven't specify the target type.

Using JSONObject can safely workaround the side effect while keeping the semanic of mapping