Skip to content

Commit 4e03810

Browse files
authored
Fix doc comments (#151)
1 parent bbe7ee0 commit 4e03810

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

arshal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func putStructOptions(o *jsonopts.Struct) {
124124
// is recursively encoded as a name and value pair in the JSON object.
125125
// The Go map key must encode as a JSON string, otherwise this results
126126
// in a [SemanticError]. The Go map is traversed in a non-deterministic order.
127-
// For deterministic encoding, consider using [jsontext.Value.Canonicalize].
127+
// For deterministic encoding, consider using the [Deterministic] option.
128128
// If the format is "emitnull", then a nil map is encoded as a JSON null.
129129
// If the format is "emitempty", then a nil map is encoded as an empty JSON object,
130130
// regardless of whether [FormatNilMapAsNull] is specified.
@@ -335,7 +335,7 @@ func marshalEncode(out *jsontext.Encoder, in any, mo *jsonopts.Struct) (err erro
335335
// - A Go float is decoded from a JSON number.
336336
// It must be decoded from a JSON string containing a JSON number
337337
// if [StringifyNumbers] is specified or decoding a JSON object name.
338-
// The JSON number is parsed as the closest representable Go float value.
338+
// It fails if it overflows the representation of the Go float type.
339339
// If the format is "nonfinite", then the JSON strings
340340
// "NaN", "Infinity", and "-Infinity" are decoded as NaN, +Inf, and -Inf.
341341
// Otherwise, the presence of such strings results in a [SemanticError].

jsontext/decode.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ func (d *decodeBuffer) PreviousTokenOrValue() []byte {
285285
}
286286

287287
// PeekKind retrieves the next token kind, but does not advance the read offset.
288-
// It returns 0 if there are no more tokens.
288+
//
289+
// It returns 0 if an error occurs. Any such error is cached until
290+
// the next read call and it is the caller's responsibility to eventually
291+
// follow up a PeekKind call with a read call.
289292
func (d *Decoder) PeekKind() Kind {
290293
return d.s.PeekKind()
291294
}

jsontext/options.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ import (
1717
// Each function takes in a variadic list of options, where properties
1818
// set in latter options override the value of previously set properties.
1919
//
20+
// There is a single Options type, which is used with both encoding and decoding.
21+
// Some options affect both operations, while others only affect one operation:
22+
//
23+
// - [AllowDuplicateNames] affects encoding and decoding
24+
// - [AllowInvalidUTF8] affects encoding and decoding
25+
// - [EscapeForHTML] affects encoding only
26+
// - [EscapeForJS] affects encoding only
27+
// - [PreserveRawStrings] affects encoding only
28+
// - [CanonicalizeRawInts] affects encoding only
29+
// - [CanonicalizeRawFloats] affects encoding only
30+
// - [ReorderRawObjects] affects encoding only
31+
// - [SpaceAfterColon] affects encoding only
32+
// - [SpaceAfterComma] affects encoding only
33+
// - [Multiline] affects encoding only
34+
// - [WithIndent] affects encoding only
35+
// - [WithIndentPrefix] affects encoding only
36+
//
37+
// Options that do not affect a particular operation are ignored.
38+
//
2039
// The Options type is identical to [encoding/json.Options] and
2140
// [encoding/json/v2.Options]. Options from the other packages may
2241
// be passed to functionality in this package, but are ignored.

options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import (
6161
// - [Deterministic] affects marshaling only
6262
// - [FormatNilSliceAsNull] affects marshaling only
6363
// - [FormatNilMapAsNull] affects marshaling only
64+
// - [OmitZeroStructFields] affects marshaling only
6465
// - [MatchCaseInsensitiveNames] affects marshaling and unmarshaling
6566
// - [DiscardUnknownMembers] affects marshaling only
6667
// - [RejectUnknownMembers] affects unmarshaling only

0 commit comments

Comments
 (0)