Done except > http://codereview.appspot.com/953041/diff/2001/3005#newcode118 > src/pkg/json/decode_test.go:118: Int64 int64 > there should be a tag in ...
14 years, 11 months ago
(2010-04-21 23:15:33 UTC)
#3
On Apr 21, 2010, at 4:15 PM, Russ Cox wrote: > Done except > >> ...
14 years, 11 months ago
(2010-04-21 23:21:15 UTC)
#4
On Apr 21, 2010, at 4:15 PM, Russ Cox wrote:
> Done except
>
>> http://codereview.appspot.com/953041/diff/2001/3005#newcode118
>> src/pkg/json/decode_test.go:118: Int64 int64
>> there should be a tag in here somewhere
>
> Do you mean a struct field tag like "foo" ?
> The json code doesn't consult struct field tags at all.
then fix the doc comment please.
-rob
*** Submitted as http://code.google.com/p/go/source/detail?r=500ccf4f55f5 *** json: Marshal, Unmarshal using new scanner R=r CC=golang-dev http://codereview.appspot.com/953041
14 years, 11 months ago
(2010-04-21 23:40:57 UTC)
#7
nag http://codereview.appspot.com/953041/diff/12002/22006 File src/pkg/json/encode.go (right): http://codereview.appspot.com/953041/diff/12002/22006#newcode57 src/pkg/json/encode.go:57: func Marshal(v interface{}) ([]byte, os.Error) { before this ...
14 years, 11 months ago
(2010-04-22 08:38:34 UTC)
#8
nag
http://codereview.appspot.com/953041/diff/12002/22006
File src/pkg/json/encode.go (right):
http://codereview.appspot.com/953041/diff/12002/22006#newcode57
src/pkg/json/encode.go:57: func Marshal(v interface{}) ([]byte, os.Error) {
before this worked with an io.Writer, now it returns a byte slice
this means for very large objects more memory is needed (transiently)
where i used to have:
err = json.MarshalIndent(b, details, " ")
(b provides io.Writer)
I now have to get a byte slice back and use WriteFile
yes, that's what it means. it also means that if the code encounters an error ...
14 years, 11 months ago
(2010-04-22 08:41:31 UTC)
#9
yes, that's what it means.
it also means that if the code encounters an
error halfway through marshalling, you don't
end up with a half-written file.
you win some, you lose some.
russ
On Thu, Apr 22, 2010 at 01:41:26AM -0700, Russ Cox wrote: > yes, that's what ...
14 years, 11 months ago
(2010-04-22 09:02:53 UTC)
#10
On Thu, Apr 22, 2010 at 01:41:26AM -0700, Russ Cox wrote:
> yes, that's what it means.
> it also means that if the code encounters an
> error halfway through marshalling, you don't
> end up with a half-written file.
i write to a temporary file and rename when it's done, that way i
don't get hosed configuration
> you win some, you lose some.
true
i'm wondering if we can't have a common interface for json and gobs (and potentially ...
14 years, 10 months ago
(2010-04-27 18:41:22 UTC)
#11
i'm wondering if we can't have a common interface for json and gobs (and
potentially other things later)
http://codereview.appspot.com/953041/diff/12002/22004
File src/pkg/json/decode.go (left):
http://codereview.appspot.com/953041/diff/12002/22004#oldcode44
src/pkg/json/decode.go:44: }
Forgive me if I'm missing something here.
But is there not an opportunity to have a common Unmarshaler interface for gobs
and json (and potentially other things in the future)?
> But is there not an opportunity to have a common Unmarshaler interface > for ...
14 years, 10 months ago
(2010-04-27 18:51:32 UTC)
#12
> But is there not an opportunity to have a common Unmarshaler interface
> for gobs and json (and potentially other things in the future)?
Sure but at a higher level. All the top-level gob and json stuff
uses the same signature now. (Compare godoc gob .*coder and godoc json .*coder)
This is about encoding a single item and is looked for
by the respective decoders, like fmt looks for the String method.
When the json unmarshaller does a dynamic interface check
to see if the object knows how to json unmarshal itself, it
had better not use the gob unmarshaller instead.
Russ
On Tue, Apr 27, 2010 at 11:51:28AM -0700, Russ Cox wrote: > When the json ...
14 years, 10 months ago
(2010-04-27 18:56:30 UTC)
#13
On Tue, Apr 27, 2010 at 11:51:28AM -0700, Russ Cox wrote:
> When the json unmarshaller does a dynamic interface check
> to see if the object knows how to json unmarshal itself, it
> had better not use the gob unmarshaller instead.
ok, that makes perfect sense, i was thinking about it from the wrong
end
thanks!
Issue 953041: code review 953041: json: Marshal, Unmarshal using new scanner
(Closed)
Created 14 years, 11 months ago by rsc
Modified 14 years, 10 months ago
Reviewers: cw
Base URL:
Comments: 11