Skip to content

Replace System.Text.Json with SimpleJSON#108

Merged
danipen merged 2 commits intomasterfrom
remove-system-text-json
Feb 3, 2026
Merged

Replace System.Text.Json with SimpleJSON#108
danipen merged 2 commits intomasterfrom
remove-system-text-json

Conversation

@danipen
Copy link
Owner

@danipen danipen commented Jan 30, 2026

Summary

Removes System.Text.Json dependency and replaces it with SimpleJSON - a single-file, zero-dependency JSON parser.

Motivation

System.Text.Json pulls in multiple transitive dependencies for .NET Standard 2.0:

  • Microsoft.Bcl.AsyncInterfaces
  • System.Buffers
  • System.IO.Pipelines
  • System.Memory
  • System.Runtime.CompilerServices.Unsafe
  • System.Text.Encodings.Web
  • System.Threading.Tasks.Extensions

This makes integration with Unity projects cumbersome.

Changes

  • Added SimpleJSON.cs to TextMateSharp/Internal/Parser/Json/
  • Rewrote JSONPListParser.cs to use SimpleJSON
  • Rewrote GrammarDefinition.cs with manual parsing (removed [JsonPropertyName] attributes)
  • Rewrote LanguageConfiguration.cs - replaced 6 custom JsonConverter<T> classes with direct parsing
  • Updated RegistryOptions.cs to use new parsing methods
  • Removed JsonSerializationContext.cs (source generator no longer needed)
  • Removed System.Text.Json PackageReference from both .csproj files

Notes

  • SimpleJSON handles trailing commas and // line comments (same as original)
  • Added GetNullableString() helper to preserve null semantics (SimpleJSON returns empty string for missing keys)
  • Memory usage slightly different: now loads full file vs streaming, acceptable for grammar files (<100KB)

Disclaimer: I created this PR using Claude Opus 4.5

@danipen danipen merged commit 4532112 into master Feb 3, 2026
5 of 6 checks passed
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.

1 participant