anchor.diff:            writeln('}');
           });
         }
  +
  +      //
  +      // fromJson(JsonObject) factory constructor, example:
  +//      public JsonObject toJson(JsonObject jsonObject) {
  +//          String x = jsonObject.get("x").getAsString();
  +//          return new Y(x);
  +//        }
  +      publicMethod('fromJson', () {
  +        writeln('public static ${className} fromJson(JsonObject jsonObject) {');
  +        indent(() {
  +          for (TypeObjectField field in fields) {
  +            write('${javaType(field.type)} ${javaName(field.name)} = ');
  +            if (field.optional) {
  +              write(
  +                  'jsonObject.get("${javaName(field.name)}") == null ? null : ');
  +            }
  +            if (isDeclaredInSpec(field.type)) {
  +              write('${javaType(field.type)}.fromJson(');
  +              write(
  +                  'jsonObject.get("${javaName(field.name)}").getAsJsonObject())');
  +            } else {
  +              if (isList(field.type)) {
  +                if (javaType(field.type).endsWith('<String>')) {
  +                  write(
  +                      'JsonUtilities.decodeStringList(jsonObject.get("${javaName(field.name)}").${_getAsTypeMethodName(field.type)}())');
  +                } else {
  +                  write(
  +                      '${javaType((field.type as TypeList).itemType)}.fromJsonArray(jsonObject.get("${javaName(field.name)}").${_getAsTypeMethodName(field.type)}())');
  +                }
  +              } else if (isArray(field.type)) {
  +                if (javaType(field.type).startsWith('Integer')) {
  +                  write(
  +                      'JsonUtilities.decodeIntegerArray(jsonObject.get("${javaName(field.name)}").${_getAsTypeMethodName(field.type)}())');
  +                }
  +              } else {
  +                write(
  +                    'jsonObject.get("${javaName(field.name)}").${_getAsTypeMethodName(field.type)}()');
  +              }
  +            }
  +            writeln(';');
  +          }
  +          write('return new ${className}(');
  +          List<String> parameters = new List();
  +          for (TypeObjectField field in fields) {
  +            parameters.add('${javaName(field.name)}');
  +          }
  +          write(parameters.join(', '));
  +          writeln(');');
  +        });
  +        writeln('}');
  +      });
  +
  +      //
  +      // fromJson(JsonArray) factory constructor
  +      //
  +      publicMethod('fromJsonArray', () {
  +        writeln(
  +            'public static List<${className}> fromJsonArray(JsonArray jsonArray) {');
  +        indent(() {
  +          writeln('if (jsonArray == null) {');
  +          writeln('  return EMPTY_LIST;');
  +          writeln('}');
  +          writeln(
  +              'ArrayList<${className}> list = new ArrayList<${className}>(jsonArray.size());');
  +          writeln('Iterator<JsonElement> iterator = jsonArray.iterator();');
  +          writeln('while (iterator.hasNext()) {');
  +          writeln('  list.add(fromJson(iterator.next().getAsJsonObject()));');
  +          writeln('}');
  +          writeln('return list;');
  +        });
  +        writeln('}');
  +      });
   
         //
         // toJson() method, example:
  
positive.code:     writeln('import java.util.Arrays;');
      writeln('import java.util.List;');
      writeln('import java.util.Map;');
      writeln('import com.google.dart.server.utilities.general.ObjectUtilities;');
      writeln('import com.google.gson.JsonArray;');
      writeln('import com.google.gson.JsonObject;');
      writeln('import com.google.gson.JsonPrimitive;');
      writeln('import org.apache.commons.lang3.StringUtils;');
      writeln();
      javadocComment(toHtmlVisitor.collectHtml(() {
  
negative.code:       // i.e. "public static final Parameter[] EMPTY_ARRAY = new Parameter[0];"
        //
        publicField(javaName("EMPTY_ARRAY"), () {
          writeln(
              'public static final ${className}[] EMPTY_ARRAY = new ${className}[0];');
        });
  
        //
        // public static final "EMPTY_LIST" field
        //
        // i.e. "public static final List<Parameter> EMPTY_LIST = Lists.newArrayList();"
        //
        publicField(javaName("EMPTY_LIST"), () {
          writeln(
              'public static final List<${className}> EMPTY_LIST = Lists.newArrayList();');
        });
  
        //
        // Extra fields on the Element type such as:
        // private static final int ABSTRACT = 0x01;
        //
        if (className == 'Element') {
  