Skip to content

Commit fc4f203

Browse files
authored
Use json v2 directly, move utils to new jsonutil package (#1504)
1 parent 62d310a commit fc4f203

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+81
-104
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ linters:
6868
main:
6969
deny:
7070
- pkg: 'encoding/json$'
71-
desc: 'Use "github.com/microsoft/typescript-go/internal/json" instead.'
71+
desc: 'Use "github.com/go-json-experiment/json" instead.'
7272

7373
exclusions:
7474
rules:

internal/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"fmt"
77
"sync"
88

9+
"github.com/go-json-experiment/json"
910
"github.com/microsoft/typescript-go/internal/api/encoder"
1011
"github.com/microsoft/typescript-go/internal/ast"
1112
"github.com/microsoft/typescript-go/internal/astnav"
1213
"github.com/microsoft/typescript-go/internal/checker"
1314
"github.com/microsoft/typescript-go/internal/core"
14-
"github.com/microsoft/typescript-go/internal/json"
1515
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
1616
"github.com/microsoft/typescript-go/internal/project"
1717
"github.com/microsoft/typescript-go/internal/tsoptions"

internal/api/proto.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"strconv"
77
"strings"
88

9+
"github.com/go-json-experiment/json"
10+
"github.com/go-json-experiment/json/jsontext"
911
"github.com/microsoft/typescript-go/internal/ast"
1012
"github.com/microsoft/typescript-go/internal/checker"
1113
"github.com/microsoft/typescript-go/internal/core"
12-
"github.com/microsoft/typescript-go/internal/json"
1314
"github.com/microsoft/typescript-go/internal/project"
1415
)
1516

@@ -200,7 +201,7 @@ type GetSourceFileParams struct {
200201
FileName string `json:"fileName"`
201202
}
202203

203-
func unmarshalPayload(method string, payload json.Value) (any, error) {
204+
func unmarshalPayload(method string, payload jsontext.Value) (any, error) {
204205
unmarshaler, ok := unmarshalers[Method(method)]
205206
if !ok {
206207
return nil, fmt.Errorf("unknown API method %q", method)

internal/api/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"strconv"
1010
"sync"
1111

12+
"github.com/go-json-experiment/json"
1213
"github.com/microsoft/typescript-go/internal/bundled"
1314
"github.com/microsoft/typescript-go/internal/core"
14-
"github.com/microsoft/typescript-go/internal/json"
1515
"github.com/microsoft/typescript-go/internal/project"
1616
"github.com/microsoft/typescript-go/internal/vfs"
1717
"github.com/microsoft/typescript-go/internal/vfs/osvfs"

internal/collections/ordered_map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"slices"
1010
"strconv"
1111

12+
"github.com/go-json-experiment/json"
1213
"github.com/go-json-experiment/json/jsontext"
13-
"github.com/microsoft/typescript-go/internal/json"
1414
)
1515

1616
// OrderedMap is an insertion ordered map.

internal/collections/ordered_map_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"slices"
66
"testing"
77

8+
"github.com/go-json-experiment/json"
89
"github.com/microsoft/typescript-go/internal/collections"
9-
"github.com/microsoft/typescript-go/internal/json"
1010
"gotest.tools/v3/assert"
1111
)
1212

internal/compiler/program.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
"strings"
99
"sync"
1010

11+
"github.com/go-json-experiment/json"
1112
"github.com/microsoft/typescript-go/internal/ast"
1213
"github.com/microsoft/typescript-go/internal/binder"
1314
"github.com/microsoft/typescript-go/internal/checker"
1415
"github.com/microsoft/typescript-go/internal/collections"
1516
"github.com/microsoft/typescript-go/internal/core"
1617
"github.com/microsoft/typescript-go/internal/diagnostics"
17-
"github.com/microsoft/typescript-go/internal/json"
1818
"github.com/microsoft/typescript-go/internal/module"
1919
"github.com/microsoft/typescript-go/internal/modulespecifiers"
2020
"github.com/microsoft/typescript-go/internal/outputpaths"

internal/core/core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"unicode"
1010
"unicode/utf8"
1111

12-
"github.com/microsoft/typescript-go/internal/json"
12+
"github.com/microsoft/typescript-go/internal/jsonutil"
1313
"github.com/microsoft/typescript-go/internal/stringutil"
1414
"github.com/microsoft/typescript-go/internal/tspath"
1515
)
@@ -427,7 +427,7 @@ func FirstResult[T1 any](t1 T1, _ ...any) T1 {
427427
}
428428

429429
func StringifyJson(input any, prefix string, indent string) (string, error) {
430-
output, err := json.MarshalIndent(input, prefix, indent)
430+
output, err := jsonutil.MarshalIndent(input, prefix, indent)
431431
return string(output), err
432432
}
433433

internal/diagnostics/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"strings"
2121
"unicode"
2222

23-
"github.com/microsoft/typescript-go/internal/json"
23+
"github.com/go-json-experiment/json"
2424
"github.com/microsoft/typescript-go/internal/repo"
2525
)
2626

internal/execute/tsc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/microsoft/typescript-go/internal/diagnostics"
1515
"github.com/microsoft/typescript-go/internal/format"
1616
"github.com/microsoft/typescript-go/internal/incremental"
17-
"github.com/microsoft/typescript-go/internal/json"
17+
"github.com/microsoft/typescript-go/internal/jsonutil"
1818
"github.com/microsoft/typescript-go/internal/parser"
1919
"github.com/microsoft/typescript-go/internal/pprof"
2020
"github.com/microsoft/typescript-go/internal/tsoptions"
@@ -413,7 +413,7 @@ func emitFilesAndReportErrors(
413413

414414
func showConfig(sys System, config *core.CompilerOptions) {
415415
// !!!
416-
_ = json.MarshalIndentWrite(sys.Writer(), config, "", " ")
416+
_ = jsonutil.MarshalIndentWrite(sys.Writer(), config, "", " ")
417417
}
418418

419419
func listFiles(sys System, program compiler.ProgramLike) {

0 commit comments

Comments
 (0)