File tree Expand file tree Collapse file tree 6 files changed +15
-126
lines changed
grails-converters/src/main/groovy
org/grails/web/converters
grails-test-suite-web/src/test/groovy/org/grails/web/converters Expand file tree Collapse file tree 6 files changed +15
-126
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,9 @@ else if (o instanceof CharSequence) {
185185 else if (o instanceof Class <?>) {
186186 writer .value (((Class <?>) o ).getName ());
187187 }
188+ else if (o instanceof Enum ) {
189+ writer .value (((Enum <?>) o ).name ());
190+ }
188191 else if (o instanceof Number ) {
189192 writer .value ((Number ) o );
190193 } else if (o instanceof Boolean ) {
Original file line number Diff line number Diff line change @@ -171,6 +171,9 @@ public void convertAnother(Object o) throws ConverterException {
171171 else if (o instanceof Class <?>) {
172172 writer .characters (((Class <?>) o ).getName ());
173173 }
174+ else if (o instanceof Enum ) {
175+ writer .characters (((Enum <?>) o ).name ());
176+ }
174177 else if ((o .getClass ().isPrimitive () && !o .getClass ().equals (byte [].class )) ||
175178 o instanceof Number || o instanceof Boolean ) {
176179 writer .characters (String .valueOf (o ));
Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ private void initJSONConfiguration() {
9595 marshallers .add (new org .grails .web .converters .marshaller .json .ByteArrayMarshaller ());
9696 marshallers .add (new org .grails .web .converters .marshaller .json .CollectionMarshaller ());
9797 marshallers .add (new org .grails .web .converters .marshaller .json .MapMarshaller ());
98- marshallers .add (new org .grails .web .converters .marshaller .json .EnumMarshaller ());
9998 marshallers .add (new org .grails .web .converters .marshaller .ProxyUnwrappingMarshaller <>());
10099
101100 Config grailsConfig = getGrailsConfig ();
@@ -177,7 +176,6 @@ private void initXMLConfiguration() {
177176 marshallers .add (new org .grails .web .converters .marshaller .xml .ArrayMarshaller ());
178177 marshallers .add (new org .grails .web .converters .marshaller .xml .CollectionMarshaller ());
179178 marshallers .add (new org .grails .web .converters .marshaller .xml .MapMarshaller ());
180- marshallers .add (new org .grails .web .converters .marshaller .xml .EnumMarshaller ());
181179 marshallers .add (new org .grails .web .converters .marshaller .xml .DateMarshaller ());
182180 marshallers .add (new ProxyUnwrappingMarshaller <>());
183181 marshallers .add (new org .grails .web .converters .marshaller .xml .ToStringBeanMarshaller ());
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -94,13 +94,14 @@ class JSONConverterTests extends Specification implements ControllerUnitTest<JSO
9494 when :
9595 def enumInstance = Role . HEAD
9696 params. e = enumInstance
97- controller. testEnum()
97+ controller. testEnumInMap()
98+ def jsonString = response. contentAsString
9899 def json = response. json
99100
100101 then :
101- json. enumType == " org.grails.web.converters.Role "
102- json . name == " HEAD"
103- json. size() == 2
102+ json. size() == 1
103+ jsonString == ' {"value":" HEAD"} '
104+ json. value == " HEAD "
104105 }
105106
106107 // GRAILS-11513
@@ -196,6 +197,10 @@ class JSONConverterController {
196197 render params. e as JSON
197198 }
198199
200+ def testEnumInMap = {
201+ render([value : params. e] as JSON )
202+ }
203+
199204 def testNullValues = {
200205 def descriptors = [:]
201206 descriptors. put(null ,null )
You can’t perform that action at this time.
0 commit comments