flavray / avro-rs

Avro client library implementation in Rust
MIT License
169 stars 95 forks source link

support to convert avro value to json value #155

Closed aananthram closed 4 years ago

aananthram commented 4 years ago

I have a use case that would benefit from being able to convert the Avro Value to a Json Value easily.

aananthram commented 4 years ago

I have not tried transcode. I'm not super familiar with it, but would that actually serialize the json in the end or keep it as a JsonValue?

poros commented 4 years ago

I have not tried transcode. I'm not super familiar with it, but would that actually serialize the json in the end or keep it as a JsonValue?

I have never use it myself, but I think this works with serializers, so I assume you'll end up with the "serialized" (or "written") output at the end.

aananthram commented 4 years ago

@poros do you have an alternate to map_or for the tests? it works well locally but fails for CI

poros commented 4 years ago

Thanks for adding the tests!

It fails for CI because map_or has been added in version 1.41, while we target a minimum supported version of 1.40. I am not opposed to bumping this up, as the next release is already backward-incompatible.

Anyway, I don't believe you are forced to use map_or here. You should be able to do something like

assert_eq!(JsonValue::try_from(Value::Boolean(true)).unwrap(), JsonValue::Bool(true));

Would this be OK?

poros commented 4 years ago

Could you also please pull master? I think your PR now has some minor conflicts.

poros commented 4 years ago

I'm planning to cut the 0.11 release before the end of the week, in case you'd like your change to get released sooner than later.

poros commented 4 years ago

Perfect! Thanks for the quick fix :)