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.
| public static JSONElement parse(String json) { | ||
| Object value = new JsonSlurper().parseText(json); | ||
| Object converted = toGrailsJson(value); | ||
| if (converted instanceof JSONElement) { | ||
| return (JSONElement) converted; | ||
| } | ||
| throw new JSONException("JSON text must describe an object or array"); | ||
| } |
| 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% 49.5665% +0.0262%
- Complexity 16922 16943 +21
==================================================
Files 1999 2000 +1
Lines 93754 93775 +21
Branches 16420 16423 +3
==================================================
+ Hits 46446 46481 +35
+ Misses 40145 40125 -20
- Partials 7163 7169 +6
🚀 New features to boost your workflow:
|
|
Instead of using our vendored version we should just adopt the upstream version. I disagree with this change. |
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryCI - Groovy Joint Validation Build / build_grails > :grails-test-examples-spring-security-core-misc-functional-test-app-group:integrationTest
🏷️ Commit: f4e8cc7 Test FailuresSecuredControllerSpec > test login as sherlock, sherlock belongs to detective groups. All detectives have the role ADMIN (:grails-test-examples-spring-security-core-misc-functional-test-app-group:integrationTest in CI - Groovy Joint Validation Build / build_grails)Muted TestsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
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]