This is an automated email from the ASF dual-hosted git repository. opwvhk pushed a commit to branch branch-1.12 in repository https://gitbox.apache.org/repos/asf/avro.git
commit efaec65d531d625d2aa5140bbbfbe4d36ee9fdd2 Author: Oscar Westra van Holthe - Kind <[email protected]> AuthorDate: Wed Aug 7 16:25:13 2024 +0200 AVRO-4027: Fix bug in JSON object syntax (#3071) Fix bug in IDL grammar and add test. (cherry picked from commit 5a401f28be16074b696c9c3f0e20c17ea015d62d) --- lang/java/idl/src/test/idl/input/simple.avdl | 3 +++ share/idl_grammar/org/apache/avro/idl/Idl.g4 | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lang/java/idl/src/test/idl/input/simple.avdl b/lang/java/idl/src/test/idl/input/simple.avdl index 27949547a1..a2dd5e2f42 100644 --- a/lang/java/idl/src/test/idl/input/simple.avdl +++ b/lang/java/idl/src/test/idl/input/simple.avdl @@ -65,6 +65,9 @@ protocol Simple { @foo.bar.bar("foo.bar2") array<string> a = []; // An optional type with a null default value (results in a union with null first). @foo.foo.bar(42) @foo.foo.foo("3foo") string? prop = null; + // Arrays and maps can have empty defaults + array<int> numbers = []; + map<string> dictionary = {}; } /** An MD5 hash. */ diff --git a/share/idl_grammar/org/apache/avro/idl/Idl.g4 b/share/idl_grammar/org/apache/avro/idl/Idl.g4 index 6144abadc0..927962c5b7 100644 --- a/share/idl_grammar/org/apache/avro/idl/Idl.g4 +++ b/share/idl_grammar/org/apache/avro/idl/Idl.g4 @@ -138,7 +138,7 @@ unionType: Union LBrace types+=fullType (Comma types+=fullType)* RBrace; jsonValue: jsonObject | jsonArray | jsonLiteral; jsonLiteral: literal=(StringLiteral | IntegerLiteral | FloatingPointLiteral | BTrue | BFalse | Null); -jsonObject: LBrace jsonPairs+=jsonPair (Comma jsonPairs+=jsonPair)* RBrace; +jsonObject: LBrace (jsonPairs+=jsonPair (Comma jsonPairs+=jsonPair)*)? RBrace; jsonPair: name=StringLiteral Colon value=jsonValue; jsonArray: LBracket (jsonValues+=jsonValue (Comma jsonValues+=jsonValue)*)? RBracket;
