-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Is your feature request related to a problem? Please describe.
When using avro in tests, serializing and deserializing can be done using production code models. How to compare 2 avro content without using the production's code models ?
Describe the solution you'd like
Comparing json contents is much simpler and easier to debug, with a downside of losing the compile time validation (wrong field name still makes the project compilable, but will fail at runtime.
The idea is to provide a way to directly serialize and deserialize generic & comparable content to avro. kotlinx-serialization comes also with the json module, providing simple and concise json structure, and also kotlin-native and multi-platform. The JsonElement sealed class is straightforward: JsonObject, JsonArray, JsonNull and JsonPrimitive. That's all. It also comes with concise DSL to generate json content. Now, testing avro becomes much simpler!
Describe alternatives you've considered
- The native avro json reader and writer are wrapping any union inside an object to indicate the concrete type to use in the union, which is annoying when having all the fields as nullable.
- There is tech allegro converter, converting from json to avro, and vice-versa, without the wrapping object for unions