Comments (5)
I also have this issue. Problem is JObject
contains internal setter like Parent
, Next
, Previous
(which Mapster will translate type as class rather than primitive). Then, Mapster try to perform deep copy, but Parent
, Next
, Previous
are JToken
which is abstract. Currently, I solve this problem by using MapWith
to perform direct copy.
TypeAdapterConfig<JObject, JObject>.NewConfig().MapWith(src => src);
TypeAdapterConfig<JArray, JArray>.NewConfig().MapWith(src => src);
TypeAdapterConfig<JValue, JValue>.NewConfig().MapWith(src => src);
TypeAdapterConfig<JToken, JToken>.NewConfig().MapWith(src => src);
from mapster.
You can close this issue if you want, search should help others who may stumble over the same problem
from mapster.
Do you have idea to improve this? Will it help if I add another method explicitly like TypeAdapterConfig.Default.AddPrimitiveType<JObject>()
? If you have better name or better idea, pls suggest.
from mapster.
I actually like the syntax we currently have: TypeAdapterConfig<JArray, JArray>.NewConfig().MapWith(src => src);
.
It's clear and explicit and it doesn't add any extra methods to know about, so user uses the same, already known grammar set for this library. Also it helps when you're searching for a particular mapping - I can search for all lines using same pattern - TypeAdapterConfig<JValue
- finds all mappings from JValue
and TypeAdapterConfig<[^,],JValue>
finds me all mappings to JValue
.
It may be worth to put an extra line or two in docs about this, as I'm sure that many users map objects that are coming from API (cross-domain boundary) e.g. in Json or XML or other cross-platform format.
from mapster.
I just added a couple of lines for MapWith in doc.
from mapster.
Related Issues (20)
- AOT issue for Xamarin/MAUI HOT 4
- Cannot map properties that have differt names and init access modifier HOT 3
- Mapster Tool failing silently HOT 1
- Mapster.Tool ignores base interface types HOT 2
- How can I map enums HOT 4
- Map to derived type HOT 6
- Mapping to derived type not working as expected
- dotnet mapper ... -p generates code that can't be compiled.
- Compile doesn't throw exceptions while configuring with attributes
- Generic IEnumerator not disposed
- ShallowCopyForSameType(true) not working with Mapster.Tool HOT 1
- Category cluster not working with filter HOT 1
- Base class private setters not mapped to HOT 1
- Regression bug - works on 7.3.0 not on 7.4.0 HOT 2
- Can't use conditional mapping with different types of source field HOT 2
- The tool doesn't seem to work on net8.0 HOT 3
- mapster is missing NuGet package README file HOT 1
- NullReferenceException with FastExpressionCompiler HOT 1
- Value overwritten by re-mapping
- Support NET. 8.0 - Mapster.Tool HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapster.