[GODRIVER-963] canonical parameter is not respected in UnmarshalExtJSON Created: 12/Apr/19  Updated: 01/Aug/22

Status: Backlog
Project: Go Driver
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File repro.go    

 Description   

The UnmarshalExtJSON function takes a canonical parameter, but does not respect it when parsing. I've attached a repro for this.



 Comments   
Comment by Esha Bhargava [ 30/May/19 ]

As discussed in triage, the work for this is to deprecate the canonical parameter.

Comment by David Golden [ 16/Apr/19 ]

The intent was for parsers to accept – in a single pass – either format.  But we recognized that people might wish to be more restrictive.  As the canonical option is not currently documented as having any particular behavior, I think it would be reasonable to rename it to canonicalOnly (to be more self-documenting) and have false be the default spec behavior and true restrict to just the canonical format.

That preserves the API signature, but merely tightens the semantics to what the parameter implies in the first place.

Comment by Jeffrey Yemin [ 16/Apr/19 ]

I found only this one place where canonical is referenced. I'm not really sure what the intent was of including this setting.

Comment by Divjot Arora (Inactive) [ 16/Apr/19 ]

The extended JSON spec says "By default, a parser MUST accept values in either Canonical Extended JSON format or Relaxed Extended JSON format as described in this specification. A parser MAY allow users to restrict parsing to only Canonical Extended JSON format or only Relaxed Extended JSON format." The usage of "restrict" in this sentence suggests that the current behavior does not follow the spec. Also, from an API usage standpoint, it doesn't seem intuitive to have a canonical parameter but then not use/respect it while parsing.

Two possible solutions are to change the behavior to use the parameter or to deprecate it completely and change the signature to UnmarshalExtJSON(data []byte, val interface{}).

CC jeff.yemin david.golden

Comment by Ian Whalen (Inactive) [ 15/Apr/19 ]

jeff to check what the spec specifies (if anything).

Generated at Thu Feb 08 08:35:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.