Replies: 1 comment 3 replies
-
Hi, Do you know the exact format of json/avro, or are you trying to define the schema for it all on the fly? Perhaps a small code example would be helpful. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I found this example on how to write avro data to via the ocf writer.
This works when the schema is strictly defined for only one type per field AND the data that is being written out is known at compile time.
I have a program where I am reading JSON data from a REST API and then writing it to an avro schema in which every field is defined as a union of
["null", <type>]
with a default value of null to ensure forwards and backwards compatibility.I tried modifying the example above such that the struct was defined with
interface{}
as a type, but that meant that I needed to cast the values defined in the struct passed in to the writer.I also tried defining a
map[string]interface{}
as follows, but had the same issue; I needed to cast the values to be able to encode them as avro.Any ideas how I could use this library to pass in a JSON object that is a
map[string]interface{}
along with the avro schema and then dynamically build either a struct or map that I could pass to the ocfwriter?Thanks,
-- Ryan
Beta Was this translation helpful? Give feedback.
All reactions