mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
add a test case for an enum implementing JSONString
(cherry picked from commit d17bbbd4174b3d84f70a6f0fdce9edc10d846a1a)
This commit is contained in:
parent
0c5cf18255
commit
60090a7167
@ -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.
|
* A JSONString that returns a valid JSON string value.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user