Skip to content

Remove relying on "encoding/json" #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions jsonsplit.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ import (
"time"
"unicode"

jsonv1std "encoding/json"

jsonv2 "github.com/go-json-experiment/json" // TODO: Use "encoding/json/v2"
jsontext "github.com/go-json-experiment/json/jsontext" // TODO: Use "encoding/json/jsontext"
jsonv1 "github.com/go-json-experiment/json/v1" // TODO: Use "encoding/json"
Expand Down Expand Up @@ -866,7 +864,7 @@ func isPointerToZero(p reflect.Value) bool {
// but allows specifying options to override default v1 behavior.
func jsonv1Marshal(v any, o ...jsonv2.Options) ([]byte, error) {
if len(o) == 0 {
return jsonv1std.Marshal(v)
return jsonv1.Marshal(v)
}
var arr [8]jsonv2.Options
return jsonv2.Marshal(v, append(append(arr[:0], jsonv1.DefaultOptionsV1()), o...)...)
Expand All @@ -876,7 +874,7 @@ func jsonv1Marshal(v any, o ...jsonv2.Options) ([]byte, error) {
// but allows specifying options to override default v1 behavior.
func jsonv1Unmarshal(b []byte, v any, o ...jsonv2.Options) error {
if len(o) == 0 {
return jsonv1std.Unmarshal(b, v)
return jsonv1.Unmarshal(b, v)
}
var arr [8]jsonv2.Options
return jsonv2.Unmarshal(b, v, append(append(arr[:0], jsonv1.DefaultOptionsV1()), o...)...)
Expand Down
Loading