MapsterMapper / MapsterMapper/Mapster
Mapster.JsonNet does not support Enum to string mapping
Open
@andrerav is already working on this.
Since Jan 11, 2023.
bug
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
The following code attempts to map a JObject to a string.
However, the result yields the enum's int value instead of its name.
//...
typeAdapter.EnableJsonMapping();
dynamic model = new JObject();
model.enumValue = DomainEnum.Three;
var result = mapper.Map<string>(model); // { "enumValue": 2 }
- Setting up typeAdapter.Default.EnumMappingStrategy(EnumMappingStrategy.ByName) did not change the result
- Setting up the default serializer settings to use StringEnumConverter did not change the result
- Using the attribute [JsonConverter(typeof(StringEnumConverter))] on the enum did not change the result
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.