mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05:00
add a test case for an enum implementing JSONString
(cherry picked from commit d17bbbd417)
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.
|
* A JSONString that returns a valid JSON string value.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user