FroMage / jax-doclets

Set of JavaDoc doclets for modern Java annotations APIs
http://www.lunatech-labs.com/open-source/jax-doclets
GNU Lesser General Public License v3.0
26 stars 23 forks source link

JSON examples should have property names double quoted #22

Closed stanio closed 12 years ago

stanio commented 12 years ago

Per JSON specification the property names should be double quoted, otherwise it is invalid JSON syntax. The generated examples are not fully JSON "compatible" but they could be made a bit more useful by making the property name output compliant, anyway.

Proposed patch:

diff --git a/doclets/src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java b/doclets/src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java
--- a/doclets/src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java
+++ b/doclets/src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java
@@ -249,25 +249,25 @@

   private void printJSONExample() {
     around("b", "JSON Example:");
     open("pre");
     if(((JAXBConfiguration)configuration).enableJSONTypeName)
-      print("{'" + jaxbClass.getName() + "':\n");
+      print("{\"" + jaxbClass.getName() + "\":\n");
     print(" {\n");
     Collection<Attribute> attributes = jaxbClass.getAttributes();
     for (Attribute attribute : attributes) {
-      print("  '@");
+      print("  \"@");
       around("a href='#m_" + attribute.getName() + "'", attribute.getName());
-      print("': ");
+      print("\": ");
       printJSONMemberType(attribute, false);
       print(",\n");
     }
     Collection<Element> elements = jaxbClass.getElements();
     for (Element element : elements) {
-      print("   '");
+      print("   \"");
       around("a href='#m_" + element.getName() + "'", element.isWrapped() ? element.getWrapperName() : element.getName());
-      print("': ");
+      print("\": ");
       printJSONMemberType(element, true);
       print(",\n");
     }
     for (Value value : jaxbClass.getValues()) {
       print("   ");
FroMage commented 12 years ago

Fixed now

FroMage commented 12 years ago

Thanks!