Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you put comments in Avro JSON schema files?

Tags:

json

avro

I'm writing my first Avro schema, which uses JSON as the schema language. I know you cannot put comments into plain JSON, but I'm wondering if the Avro tool allows comments. E.g. Perhaps it strips them (like a preprocessor) before parsing the JSON.

Edit: I'm using the C++ Avro toolchain

like image 280
jfritz42 Avatar asked May 23 '13 01:05

jfritz42


1 Answers

According to the current (1.9.2) Avro specification it's allowed to put in extra attributes, that are not defined, as metadata:

Avro schema specification screenshot

This allows you add comments like this:

{
  "type": "record", 
  "name": "test",
  "comment": "This is a comment",
  "//": "This is also a comment",
  "TODO": "As per this comment we should remember to fix this schema" ,
  "fields" : [
    {
      "name": "a", "type": "long"
    },
    {
      "name": "b", "type": "string"
    }
  ]
}
like image 185
Rasmus Bååth Avatar answered Oct 08 '22 07:10

Rasmus Bååth