Skip to content
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

Commit v1 encoding/json #72

Merged
merged 1 commit into from
Dec 15, 2024
Merged

Commit v1 encoding/json #72

merged 1 commit into from
Dec 15, 2024

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Dec 14, 2024

This pulls in v1 of "encoding/json" at commit 99dad5281660c4e644602e0c8790dd24b3eb45f3.

Some local changes were made:

  • Remove reference to "internal/testenv".
  • Replaced all references to "encoding/json" with "github.com/go-json-experiment/json/v1".
  • Replaced test logic to read testdata/code.json.gz with local copy in ./internal/jsontest.Data.

The exact diff is as follows:

diff -U 0 go/src/encoding/json/bench_test.go jsonv2/v1/bench_test.go
--- go/src/encoding/json/bench_test.go	2024-12-11 11:08:22.381698273 -0800
+++ jsonv2/v1/bench_test.go	2024-12-14 15:27:52.619776408 -0800
@@ -15 +14,0 @@
-	"compress/gzip"
@@ -17 +15,0 @@
-	"internal/testenv"
@@ -19 +16,0 @@
-	"os"
@@ -25,0 +23,2 @@
+
+	"github.com/go-json-experiment/json/internal/jsontest"
@@ -47,12 +46,5 @@
-	f, err := os.Open("testdata/code.json.gz")
-	if err != nil {
-		panic(err)
-	}
-	defer f.Close()
-	gz, err := gzip.NewReader(f)
-	if err != nil {
-		panic(err)
-	}
-	data, err := io.ReadAll(gz)
-	if err != nil {
-		panic(err)
+	var data []byte
+	for _, entry := range jsontest.Data {
+		if entry.Name == "GolangSource" {
+			data = entry.Data()
+		}
@@ -60 +51,0 @@
-
@@ -66,0 +58 @@
+	var err error
@@ -465,3 +456,0 @@
-	if testenv.Builder() != "" {
-		maxTypes = 1e3 // restrict cache sizes on builders
-	}
diff -U 0 go/src/encoding/json/example_marshaling_test.go jsonv2/v1/example_marshaling_test.go
--- go/src/encoding/json/example_marshaling_test.go	2021-08-26 13:12:00.197473917 -0700
+++ jsonv2/v1/example_marshaling_test.go	2024-12-14 15:26:17.366263865 -0800
@@ -8 +7,0 @@
-	"encoding/json"
@@ -11,0 +11,2 @@
+
+	"github.com/go-json-experiment/json/v1"
diff -U 0 go/src/encoding/json/example_test.go jsonv2/v1/example_test.go
--- go/src/encoding/json/example_test.go	2024-12-11 10:13:36.500960427 -0800
+++ jsonv2/v1/example_test.go	2024-12-14 15:26:24.712222257 -0800
@@ -9 +8,0 @@
-	"encoding/json"
@@ -14,0 +14,2 @@
+
+	"github.com/go-json-experiment/json/v1"
diff -U 0 go/src/encoding/json/example_text_marshaling_test.go jsonv2/v1/example_text_marshaling_test.go
--- go/src/encoding/json/example_text_marshaling_test.go	2022-03-09 09:27:59.164793033 -0800
+++ jsonv2/v1/example_text_marshaling_test.go	2024-12-14 15:26:21.389145838 -0800
@@ -8 +7,0 @@
-	"encoding/json"
@@ -11,0 +11,2 @@
+
+	"github.com/go-json-experiment/json/v1"

This pulls in v1 of "encoding/json" at commit
99dad5281660c4e644602e0c8790dd24b3eb45f3.

Some local changes were made:
* Remove reference to "internal/testenv".
* Replaced all references to "encoding/json" with
  "github.com/go-json-experiment/json/v1".
* Replaced test logic to read testdata/code.json.gz
  with local copy in ./internal/jsontest.Data.

The exact diff is as follows:
    diff -U 0 go/src/encoding/json/bench_test.go jsonv2/v1/bench_test.go
    --- go/src/encoding/json/bench_test.go	2024-12-11 11:08:22.381698273 -0800
    +++ jsonv2/v1/bench_test.go	2024-12-14 15:27:52.619776408 -0800
    @@ -15 +14,0 @@
    -	"compress/gzip"
    @@ -17 +15,0 @@
    -	"internal/testenv"
    @@ -19 +16,0 @@
    -	"os"
    @@ -25,0 +23,2 @@
    +
    +	"github.com/go-json-experiment/json/internal/jsontest"
    @@ -47,12 +46,5 @@
    -	f, err := os.Open("testdata/code.json.gz")
    -	if err != nil {
    -		panic(err)
    -	}
    -	defer f.Close()
    -	gz, err := gzip.NewReader(f)
    -	if err != nil {
    -		panic(err)
    -	}
    -	data, err := io.ReadAll(gz)
    -	if err != nil {
    -		panic(err)
    +	var data []byte
    +	for _, entry := range jsontest.Data {
    +		if entry.Name == "GolangSource" {
    +			data = entry.Data()
    +		}
    @@ -60 +51,0 @@
    -
    @@ -66,0 +58 @@
    +	var err error
    @@ -465,3 +456,0 @@
    -	if testenv.Builder() != "" {
    -		maxTypes = 1e3 // restrict cache sizes on builders
    -	}
    diff -U 0 go/src/encoding/json/example_marshaling_test.go jsonv2/v1/example_marshaling_test.go
    --- go/src/encoding/json/example_marshaling_test.go	2021-08-26 13:12:00.197473917 -0700
    +++ jsonv2/v1/example_marshaling_test.go	2024-12-14 15:26:17.366263865 -0800
    @@ -8 +7,0 @@
    -	"encoding/json"
    @@ -11,0 +11,2 @@
    +
    +	"github.com/go-json-experiment/json/v1"
    diff -U 0 go/src/encoding/json/example_test.go jsonv2/v1/example_test.go
    --- go/src/encoding/json/example_test.go	2024-12-11 10:13:36.500960427 -0800
    +++ jsonv2/v1/example_test.go	2024-12-14 15:26:24.712222257 -0800
    @@ -9 +8,0 @@
    -	"encoding/json"
    @@ -14,0 +14,2 @@
    +
    +	"github.com/go-json-experiment/json/v1"
    diff -U 0 go/src/encoding/json/example_text_marshaling_test.go jsonv2/v1/example_text_marshaling_test.go
    --- go/src/encoding/json/example_text_marshaling_test.go	2022-03-09 09:27:59.164793033 -0800
    +++ jsonv2/v1/example_text_marshaling_test.go	2024-12-14 15:26:21.389145838 -0800
    @@ -8 +7,0 @@
    -	"encoding/json"
    @@ -11,0 +11,2 @@
    +
    +	"github.com/go-json-experiment/json/v1"
@dsnet
Copy link
Collaborator Author

dsnet commented Dec 15, 2024

Subsequent PRs will delete the legacy code and replace it with the v2 equivalent.

@dsnet dsnet mentioned this pull request Dec 15, 2024
@dsnet dsnet merged commit a8b2846 into master Dec 15, 2024
8 checks passed
@dsnet dsnet deleted the v1 branch December 15, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants