[
https://issues.apache.org/jira/browse/AVRO-4003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17862408#comment-17862408
]
Oscar Westra van Holthe - Kind commented on AVRO-4003:
------------------------------------------------------
Ah, this makes it much clearer. What you're after is a parsing process that
(explicitly or not) validates the incoming JSON data against the write schema.
Your rationale seems similar to what happens when Avro reads data: if the data
does not match the write schema, an exception is thrown.
For JSON data, which by its nature is a low more forgiving: i.e., extra fields
are allowed but generally ignored, and duplicate fields are generally read
using a "last one wins" approach.
Now for a devil's advocate view: can you easily guarantee the JSON is JSON
encoded Avro data? Or is it easier to use regular JSON data?
In the former case, I'd be happy to review a PR. But in the latter case (if
regular JSON is easier), you may be better off using a library like
[avro-conversions|https://github.com/opwvhk/avro-conversions]. This library
creates validating parsers that parses JSON into Avro objects.
> Option to fail when extra fields are in the payload - Java
> ----------------------------------------------------------
>
> Key: AVRO-4003
> URL: https://issues.apache.org/jira/browse/AVRO-4003
> Project: Apache Avro
> Issue Type: Improvement
> Reporter: Cameron Mayhew
> Priority: Minor
>
> Hello,
>
> This relates to: https://issues.apache.org/jira/browse/AVRO-2200
>
> Wondering if there's any plan to do the same for Java? Dealing with this
> issue currently.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)