mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-05 10:15:19 +08:00
add a test case for an enum implementing JSONString
(cherry picked from commit d17bbbd4174b3d84f70a6f0fdce9edc10d846a1a)
This commit is contained in:
@@ -319,6 +319,22 @@ public class JSONStringTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumJSONString() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("key", MyEnum.MY_ENUM);
|
||||
assertEquals("{\"key\":\"myJsonString\"}", jsonObject.toString());
|
||||
}
|
||||
|
||||
private enum MyEnum implements JSONString {
|
||||
MY_ENUM;
|
||||
|
||||
@Override
|
||||
public String toJSONString() {
|
||||
return "\"myJsonString\"";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A JSONString that returns a valid JSON string value.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user