Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1988)

Issue 4965049: code review 4965049: json: fix decode bug with struct tag names with ,opts b... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 8 months ago by bradfitz
Modified:
12 years, 8 months ago
Reviewers:
rsc
CC:
golang-dev, dvyukov
Visibility:
Public.

Description

json: fix decode bug with struct tag names with ,opts being ignored When the encoder was updated to respect the ",omitempty" struct tag options, the decoder half was never updated to know about the new struct tag format. (the format is now an optional name, followed by zero or more ",option" strings) This only affected people who used ",omitempty" along with a field name. In that case, the serialized JSON wouldn't decode to the original value.

Patch Set 1 #

Patch Set 2 : diff -r 71f597a8ca9b https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 71f597a8ca9b https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 71f597a8ca9b https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+16 lines, -2 lines) Patch
M src/pkg/json/decode.go View 1 2 chunks +11 lines, -1 line 0 comments Download
M src/pkg/json/decode_test.go View 1 4 chunks +5 lines, -1 line 0 comments Download

Messages

Total messages: 11
bradfitz
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 8 months ago (2011-08-26 07:05:40 UTC) #1
dvyukov
There can be no spaces before the comma in tags, right?
12 years, 8 months ago (2011-08-26 07:41:56 UTC) #2
dvyukov
The decodes does case-insensitive comparison of field names, but does only case-sensitive for tags. Is ...
12 years, 8 months ago (2011-08-26 07:43:23 UTC) #3
dvyukov
I am looking at the documentation "The "json" key in struct field's tag value is ...
12 years, 8 months ago (2011-08-26 07:54:14 UTC) #4
bradfitz
On Fri, Aug 26, 2011 at 11:54 AM, <dvyukov@google.com> wrote: > I am looking at ...
12 years, 8 months ago (2011-08-26 07:56:41 UTC) #5
bradfitz
On Fri, Aug 26, 2011 at 11:41 AM, <dvyukov@google.com> wrote: > There can be no ...
12 years, 8 months ago (2011-08-26 08:14:06 UTC) #6
dvyukov
In either case, even if that things are issues, they are not issues with this ...
12 years, 8 months ago (2011-08-26 08:15:18 UTC) #7
bradfitz
On Fri, Aug 26, 2011 at 11:43 AM, <dvyukov@google.com> wrote: > The decodes does case-insensitive ...
12 years, 8 months ago (2011-08-26 08:15:36 UTC) #8
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=f8e4df3c4048 *** json: fix decode bug with struct tag names with ,opts ...
12 years, 8 months ago (2011-08-26 08:27:38 UTC) #9
rsc
>> The decodes does case-insensitive comparison of field names, but does >> only case-sensitive for ...
12 years, 8 months ago (2011-08-26 20:42:04 UTC) #10
rsc
12 years, 8 months ago (2011-08-26 20:42:18 UTC) #11
>> Yes, that's how it's always been.  The default case is automatic &
>> case-insensitive.  If you override a field and specify an exact name, that
>> name is then case-sensitive.
>
> that's probably a mistake we should fix.
> it will break people's Unmarshal calls.
> we should have changed it when we broke
> people's Marshal calls by changing the
> code to not strlwr the names before using them.

that is, the mistake is the case-insensitive default.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b