Comments (4)
Makes great sense, and it works ofc :)
Thanks alot! 🍺
from dart-json-mapper.
Wow, so generous, thank you so much appreciate that. All I can do for you is my pleasure, challenge me whenever you like
from dart-json-mapper.
This library is priceless, and your ability to help and sort out issues so fast is incredible!
from dart-json-mapper.
well, that should be the easy one, it's not obvious that constructor parameter actionType
needs to be mapped to json field type
, so you should tell it explicitly how to operate:
@JsonSerializable()
class TestModel {
EActionType type = EActionType.None;
TestModel(@JsonProperty(name: 'type') EActionType actionType) {
type = actionType;
}
}
This should do the trick, if not let me know.
In your case you have different field names, but there are more cases around that, like:
- when the class field names matched to json fields it's an auto-mapping, obvious one so it works right away
- the class has read-only field
type
and you can set it via constructor only, but you are giving constructor parameter same nametype
that case is not resolved automagically yet 😄
@jsonSerializable
class Model {
EActionType _type = EActionType.None;
EActionType get type {
return _type;
}
Model(EActionType type) {
_type = type;
}
}
from dart-json-mapper.
Related Issues (20)
- ignoreNullMembers Annotation is ignored HOT 7
- Flutter Json Mapper (json_mapper) is failing to deserialize Enum HOT 1
- Can't add sources to `build.yaml` using `flutter_translate_annotations` package HOT 7
- ignoreNullMembers seems to break the deserialization HOT 2
- Problem converting enum with following uppercase character HOT 9
- Adapter for https://pub.dev/packages/fast_immutable_collections
- `main.mapper.g.dart` is not generating all `@jsonSerializable` classes HOT 6
- `JsonMapper.copyWith` doesn't respect deep merge
- Parsing error when building for web HOT 9
- Improve class instance creation error handling HOT 4
- Problem converting enum with following uppercase character - second edition :) HOT 10
- Omit serializing optional fields HOT 14
- Issues with deserialising Color HOT 3
- Dart Json Mapper looks like don't generate valueDecorators when models in different package HOT 1
- Default discriminatorValue may not work. HOT 4
- Using with Retrofit HOT 2
- Serialize generic type. HOT 1
- @Json takes no effect even if put on top class & processAnnotatedMembersOnly in option will ignore all members when serialization HOT 1
- Empty Reflectable file - regarding HOT 1
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 dart-json-mapper.