Can you put comments in Avro JSON schema files?

I am writing my first Avro schema that uses JSON as the schema language. I know that you cannot post comments in plain JSON, but I am wondering if the Avro tool allows comments to be made. For instance. Perhaps it separates them (like a preprocessor) before parsing JSON.

Edit: I am using Avro C ++ toolchain

+6
source share
3 answers

Yes, you can use C comments in the Avro JSON schema: /* something */ or // something
Avro tools ignore these expressions during parsing.
EDIT : It only works with the Java API.

+4
source

Yes, but it is limited. In the schema, data of the "record", "enum" and "fixed" type of the Avro type allows the "doc" field, which contains an arbitrary documentation line. For instance:

 {"type": "record", "name": "test.Weather", "doc": "A weather reading.", "fields": [ {"name": "station", "type": "string", "order": "ignore"}, {"name": "time", "type": "long"}, {"name": "temp", "type": "int"} ] } 

From https://github.com/apache/avro/blob/33d495840c896b693b7f37b5ec786ac1acacd3b4/share/test/schemas/weather.avsc#L2

+3
source

No, it cannot be in C ++ and C # versions (since 1.7.5). If you look at the code, they will simply put JSON into the JSON parser without first processing the comments β€” a fancy programming style. The documentation and language support look rather messy ...

+2
source

Source: https://habr.com/ru/post/945640/


All Articles