Skip to content

Use json v2 directly, move utils to new jsonutil package #1504

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

Merged
merged 3 commits into from
Aug 4, 2025

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Aug 1, 2025

Originally the json package in our repo contained some shims to adapt behavior, but then I moved everything to just be v2. Now the package serves no purpose, except for a couple of pretty printing helpers.

Those helpers needing to exist seems like a bug to me; probably worth reporting upstream.

@jakebailey
Copy link
Member Author

Ah, the behavior difference is that setting Prefix or Indent also enables multiline printing in v2. It's actually a bug in our code that we are attempting to stringify with empty prefix and indent.

@jakebailey jakebailey marked this pull request as ready for review August 1, 2025 23:44
@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 23:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the JSON handling in the codebase by removing the internal json package wrapper and migrating to direct usage of the github.com/go-json-experiment/json library. The changes include creating a new jsonutil package for pretty printing utilities and updating all imports throughout the codebase.

  • Removes the internal json package that was previously serving as a wrapper around github.com/go-json-experiment/json
  • Creates a new jsonutil package containing MarshalIndent and MarshalIndentWrite helper functions
  • Updates all imports across the codebase to use the JSON v2 library directly

Reviewed Changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/json/json.go Removes the entire internal JSON wrapper package
internal/jsonutil/jsonutil.go Creates new utility package with indent marshaling helpers
internal/tsoptions/tsconfigparsing_test.go Updates imports and function calls to use jsonutil
internal/lsp/lsproto/jsonrpc.go Changes json.Value to jsontext.Value for RPC parameters
.golangci.yml Updates linter rule to reference the new direct import
(35+ other files) Updates imports from internal/json to go-json-experiment/json

@jakebailey jakebailey added this pull request to the merge queue Aug 4, 2025
Merged via the queue into main with commit fc4f203 Aug 4, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/remove-json-shim branch August 4, 2025 17:51
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