You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: grails-doc/src/en/guide/upgrading/upgrading60x.adoc
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -683,3 +683,74 @@ If your application or API consumers depend on the previous JSON format for `Cal
683
683
4. **ZonedDateTime**: Note that the zone ID (e.g., `[America/Los_Angeles]`) is no longer included in the output, matching Spring Boot's behavior.
684
684
685
685
This change applies to both the `grails-converters` module (standard JSON rendering) and the `grails-views-gson` module (JSON views).
686
+
687
+
===== 12.26 Enum JSON/XML Serialization
688
+
689
+
As of Grails 7.0.2, enum serialization has been enhanced to support round-trip compatibility between JSON/XML serialization and deserialization. The legacy enum marshaller, which produced verbose output with type metadata, has been deprecated in favor of a simpler format that matches how enums are expected on input.
This format is **asymmetric** - when POSTing data, you send `"stage":"SUBMIT"`, but when GETting data, you receive the verbose object structure.
713
+
714
+
====== New Behavior (Recommended)
715
+
716
+
The new `SimpleEnumMarshaller` serializes enums as simple string values, providing **round-trip compatibility**:
717
+
718
+
*JSON:*
719
+
[source,json]
720
+
----
721
+
{
722
+
"stage": "SUBMIT"
723
+
}
724
+
----
725
+
726
+
*XML:*
727
+
[source,xml]
728
+
----
729
+
<stage>SUBMIT</stage>
730
+
----
731
+
732
+
Now the format you POST is the same format you GET back.
733
+
734
+
====== Migration
735
+
736
+
To opt-in to the new behavior, add the following to your `application.yml`:
737
+
738
+
[source,yml]
739
+
.application.yml
740
+
----
741
+
grails:
742
+
converters:
743
+
json:
744
+
enum:
745
+
format: simple
746
+
xml:
747
+
enum:
748
+
format: simple
749
+
----
750
+
751
+
====== Deprecation Timeline
752
+
753
+
* **7.0.2**: Legacy `EnumMarshaller` deprecated (default), `SimpleEnumMarshaller` available via config
754
+
* **8.0**: `SimpleEnumMarshaller` will become the default
755
+
756
+
The legacy `org.grails.web.converters.marshaller.json.EnumMarshaller` and `org.grails.web.converters.marshaller.xml.EnumMarshaller` classes are marked as `@Deprecated(forRemoval = true, since = "7.0.2")` and will be removed in Grails 8.0.
0 commit comments