question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with enum serialization

See original GitHub issue

Hiya,

This library looks very promising. We are working on integrating it with Starlite. One issue we came up with the lack of support for serializing Enum values into JSON. So we would like to report this issue.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
provinzkrautcommented, Dec 6, 2022

Can confirm that it works! I have a working branch with the Starlite integration using msgspec@mainfor about a week now! Added that as soon as you merged the Enum update. Sorry for not mentioning it sooner.

1reaction
jcristcommented, Nov 24, 2022

Thanks for opening this.

We are working on integrating it with Starlite.

Nice! Please let me know if you run into any other issues or have questions, use cases like Starlite are one of the main reasons I wrote msgspec.

they are being serialized into their respective names and not their values.

This was an early decision based on a specific use case I had at the time, but it seems like most other tools encode/decode by value instead. I’ve been thinking about changing this to match (still only string or int values for now). This issue is enough of a motivation to make that change, shouldn’t be that much work.

Are there any known workarounds for this / ways we can solve our issue?

There are not any workarounds for this unfortunately. This can only be fixed by changing the behavior in msgspec.

Can you continue integration work without this fix? I’ll hopefully have time in the next few weeks to fix this and get a new release out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Misleading documentation on serialization of enums #1248
Either the documentation should state that this holds only for enums that are serialized as fields of a class or this case should...
Read more >
java - Is custom enum Serializable too?
The process by which enum constants are serialized cannot be customized: any class-specific writeObject, readObject, readObjectNoData, writeReplace, and ...
Read more >
How To Serialize and Deserialize Enums with Jackson
In this quick tutorial, we'll learn how to control the way Java Enums are serialized and deserialized with Jackson 2.
Read more >
Enum de/serialization with REST backward compatibility ...
This can be an issue when you are working in a micro-service landscape and you are dealing with backward compatibility. A quick example....
Read more >
ALWAYS assign enum values (at least, if you serialize them)
Now, we have a big issue. This enum is serialized into an asset file (ScriptableObject), so every value has a specific number.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found