Seed groovy-json facade over org.grails.web.json#15958
Conversation
Introduce GroovyJsonFacade and begin deprecation path for the vendored JSON.org fork. Assisted-by: Sisyphus:xai/grok-4.5 [gpt-coding]
There was a problem hiding this comment.
Pull request overview
This PR seeds a GroovyJsonFacade in grails-web-common to start migrating Grails’ vendored org.grails.web.json JSON.org-era fork toward groovy-json, while keeping the existing JSONElement / JSONObject / JSONArray public facade types in place.
Changes:
- Added
GroovyJsonFacadeto parse/serialize viagroovy.json.JsonSlurper/JsonOutputwhile returning existing Grails JSON facade types. - Deprecated the internal
JSONTokeneras part of the planned removal path. - Added an upgrade note and initial Spock coverage for the new facade.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| grails-web-common/src/main/groovy/org/grails/web/json/GroovyJsonFacade.java | Introduces the new groovy-json–backed facade to bridge toward replacing the internal JSON.org fork. |
| grails-web-common/src/main/groovy/org/grails/web/json/JSONTokener.java | Deprecates the legacy tokener to steer usage toward the new facade path. |
| grails-web-common/src/test/groovy/org/grails/web/json/GroovyJsonFacadeSpec.groovy | Adds initial tests for parsing/serialization via the new facade (needs adjustments per review comments). |
| grails-web-common/build.gradle | Adds groovy-json dependency to support the new facade. |
| grails-doc/src/en/guide/upgrading/jsonGroovyJsonFacade.adoc | Documents the migration seed and 9.0 removal intent. |
| grails-doc/src/en/guide/toc.yml | Adds the new upgrading guide entry to the TOC. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect: | ||
| GroovyJsonFacade.toJson(object) == '{"name":"Grails","active":true}' |
|
|
||
| void 'toJson renders existing JSONObject facade through groovy-json'() { |
| api 'org.apache.groovy:groovy' | ||
| api 'org.apache.groovy:groovy-json' | ||
| api 'org.apache.groovy:groovy-templates' |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15958 +/- ##
==================================================
+ Coverage 49.5403% 51.1344% +1.5941%
- Complexity 16922 17617 +695
==================================================
Files 1999 2042 +43
Lines 93754 95517 +1763
Branches 16420 16591 +171
==================================================
+ Hits 46446 48842 +2396
+ Misses 40145 39382 -763
- Partials 7163 7293 +130
🚀 New features to boost your workflow:
|
|
Instead of using our vendored version we should just adopt the upstream version. I disagree with this change. |
|
Just to align on the goal - I think we actually want the same end state ("adopt upstream"), and the facade is the non-breaking route to it rather than an alternative. Per the pre-release review (Codebase 4.1): The recommended starting point there is exactly to move onto upstream
If your objection is specifically to keeping the vendored public API around at all, that's the 9.0 removal step this facade sets up. Would it help if I framed the PR explicitly as "reimplement internals on groovy-json; deprecate the public facade for 9.0 removal" so the upstream-adoption intent is unambiguous? |
|
groovy-json has behavioral differences that has blocked me on trying this before and changing the json parsing stack is a major change. I'd rather we update to the successor of what was vendored, which in this case is openjson. It's a clean room implementation that is maintained, and it was driven by the ASF having problems with the original library. This maintains strict compatibility and is less likely to introduce regressions to behavioral differences. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
✅ All tests passed ✅🏷️ Commit: 125bb6c Learn more about TestLens at testlens.app. |
Description
What was found
org.grails.web.jsonis a vendored JSON.org-era forkWhat changed
GroovyJsonFacadebridging towardgroovy-jsonorg.grails.web.jsontypesOut of scope / follow-up
Related MD topics
Contributor Checklist
Issue and Scope
8.0.x.Code Quality
Licensing and Attribution
ai-generated-starting-pointlabel applied.Documentation
Assisted-by: Sisyphus:xai/grok-4.5 [gpt-coding]