How to get enums to serialize with the java classname?

12 views
Skip to first unread message

brad.l...@gmail.com

unread,
Jun 22, 2015, 8:21:45 AM6/22/15
to json-...@googlegroups.com
Hi,
    Right now when I use the Json Schema Factory to serialize an enum property, it outputs something like the below:

"    \"myEnumProp\" : {\n" +
" \"type\" : \"string\",\n" +
" \"enum\" : [ \"FOO\", \"BAR\", \"BAZ\", \"QUX\" ]\n" +
" },\n" +


   As I'm using the emitted json schema to drive a code generator, it would be helpful if I could obtain the java classname of the the enum from the emitted schema. This would be similar to how Json Schema populates the 'id' field of emitted objects with something like:

"  \"id\" : \"urn:jsonschema:org:acme:MyObjectClass\",\n"


So, is it possible to emit the 'id' field of an enum with a fully-qualified java classname (or any other way of getting the classname from emitted enum schema), and if so, where to start...

"    \"myEnumProp\" : {\n" +
"  \"id\" : \"urn:jsonschema:org:acme:MyEnumClass\",\n"
" \"type\" : \"string\",\n" +
"      \"enum\" : [ \"FOO\", \"BAR\", \"BAZ\", \"QUX\" ]\n" +
" },\n" +

Thanks,
Brad


Reply all
Reply to author
Forward
0 new messages