-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
108 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package stablejson | ||
|
||
import ( | ||
"strings" | ||
io "io" | ||
|
||
"google.golang.org/protobuf/reflect/protoreflect" | ||
) | ||
|
||
const () | ||
|
||
func marshalDuration(writer *strings.Builder, message protoreflect.Message) error { | ||
func marshalDuration(writer io.Writer, message protoreflect.Message) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
package stablejson | ||
|
||
import ( | ||
"io" | ||
"math" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func marshalFloat(writer *strings.Builder, x float64) { | ||
func marshalFloat(writer io.Writer, x float64) error { | ||
// PROTO3 SPEC: | ||
// JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". | ||
// Either numbers or strings are accepted. Exponent notation is also accepted. | ||
// -0 is considered equivalent to 0. | ||
var err error | ||
if math.IsInf(x, -1) { | ||
writer.WriteString("-Infinity") | ||
_, err = writer.Write([]byte("-Infinity")) | ||
} else if math.IsInf(x, 1) { | ||
writer.WriteString("Infinity") | ||
_, err = writer.Write([]byte("Infinity")) | ||
} else if math.IsNaN(x) { | ||
writer.WriteString("NaN") | ||
_, err = writer.Write([]byte("NaN")) | ||
} else { | ||
writer.WriteString(strconv.FormatFloat(x, 'f', -1, 64)) | ||
_, err = writer.Write([]byte(strconv.FormatFloat(x, 'f', -1, 64))) | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.