+Index: src/google/protobuf/compiler/javamicro/javamicro_primitive_field.h
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- src/google/protobuf/compiler/javamicro/javamicro_primitive_field.h	(revision ce2f59915e0b41c935e3f72a2b7b71b6c19b6860)
++++ src/google/protobuf/compiler/javamicro/javamicro_primitive_field.h	(revision )
+@@ -55,6 +55,7 @@
+   void GenerateParsingCode(io::Printer* printer) const;
+   void GenerateSerializationCode(io::Printer* printer) const;
+   void GenerateSerializedSizeCode(io::Printer* printer) const;
++  void GenerateToJSONCode(io::Printer* printer) const;
+ 
+   string GetBoxedType() const;
+ 
+@@ -76,6 +77,7 @@
+   void GenerateParsingCode(io::Printer* printer) const;
+   void GenerateSerializationCode(io::Printer* printer) const;
+   void GenerateSerializedSizeCode(io::Printer* printer) const;
++  void GenerateToJSONCode(io::Printer* printer) const;
+ 
+   string GetBoxedType() const;
+ 
+@@ -88,7 +90,4 @@
+ 
+ }  // namespace javamicro
+ }  // namespace compiler
+-}  // namespace protobuf
+-
+-}  // namespace google
+-#endif  // GOOGLE_PROTOBUF_COMPILER_JAVAMICRO_PRIMITIVE_FIELD_H__
++}  //
+\ No newline at end of file
 Index: src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc
 IDEA additional info:
 Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
 <+>UTF-8
 ===================================================================
---- src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc	(revision 51ef8f39de376fe71ce5d2c682abe4f974cf8074)
+--- src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc	(revision ce2f59915e0b41c935e3f72a2b7b71b6c19b6860)
 +++ src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc	(revision )
 @@ -198,8 +198,9 @@
    if (IsReferenceType(GetJavaType(descriptor))) {

   } else {
     (*variables)["null_check"] = "";
   }
Index: src/google/protobuf/compiler/javamicro/javamicro_message_field.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/google/protobuf/compiler/javamicro/javamicro_message_field.cc	(revision 51ef8f39de376fe71ce5d2c682abe4f974cf8074)
+++ src/google/protobuf/compiler/javamicro/javamicro_message_field.cc	(revision )
@@ -89,7 +89,8 @@
     "public $type$ get$capitalized_name$() { return $name$_; }\n"
     "public $message_name$ set$capitalized_name$($type$ value) {\n"
     "  if (value == null) {\n"
-    "    throw new NullPointerException();\n"
+//    "    throw new NullPointerException();\n"
+    "    return clear$capitalized_name$();"
     "  }\n"
     "  has$capitalized_name$ = true;\n"
     "  $name$_ = value;\n"
@@ -172,14 +173,16 @@
       "}\n"
       "public $message_name$ set$capitalized_name$(int index, $type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.setElementAt(value, index);\n"
       "  return this;\n"
       "}\n"
       "public $message_name$ add$capitalized_name$($type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.addElement(value);\n"
       "  return this;\n"
@@ -201,14 +204,16 @@
       "}\n"
       "public $message_name$ set$capitalized_name$(int index, $type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.set(index, value);\n"
       "  return this;\n"
       "}\n"
       "public $message_name$ add$capitalized_name$($type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  if ($name$_.isEmpty()) {\n"
       "    $name$_ = new java.util.ArrayList<$type$>();\n"
Index: src/google/protobuf/compiler/javamicro/javamicro_message.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/google/protobuf/compiler/javamicro/javamicro_message.cc	(revision 51ef8f39de376fe71ce5d2c682abe4f974cf8074)
+++ src/google/protobuf/compiler/javamicro/javamicro_message.cc	(revision )
@@ -363,12 +363,22 @@
     "  return ($classname$) (new $classname$().mergeFrom(data));\n"
     "}\n"
     "\n"

     "classname", descriptor_->name());
 }
 
@@ -477,4 +509,4 @@
 }  // namespace javamicro
 }  // namespace compiler
 }  // namespace protobuf
-}  // namespace google
+}  // namespace google
\ No newline at end of file
Index: src/google/protobuf/compiler/javamicro/javamicro_enum_field.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/google/protobuf/compiler/javamicro/javamicro_enum_field.h	(revision ce2f59915e0b41c935e3f72a2b7b71b6c19b6860)
+++ src/google/protobuf/compiler/javamicro/javamicro_enum_field.h	(revision )
@@ -55,6 +55,7 @@
   void GenerateParsingCode(io::Printer* printer) const;
   void GenerateSerializationCode(io::Printer* printer) const;
   void GenerateSerializedSizeCode(io::Printer* printer) const;
+  void GenerateToJSONCode(io::Printer* printer) const;
 
   string GetBoxedType() const;
 
@@ -76,6 +77,7 @@
   void GenerateParsingCode(io::Printer* printer) const;
   void GenerateSerializationCode(io::Printer* printer) const;
   void GenerateSerializedSizeCode(io::Printer* printer) const;
+  void GenerateToJSONCode(io::Printer* printer) const;
 
   string GetBoxedType() const;
 
@@ -87,8 +89,4 @@
 };
 
 }  // namespace javamicro
-}  // namespace compiler
-}  // namespace protobuf
-
-}  // namespace google
-#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
+}  // namespace comp
\ No newline at end of file
Index: src/google/protobuf/compiler/javamicro/javamicro_message_field.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/google/protobuf/compiler/javamicro/javamicro_message_field.cc	(revision ce2f59915e0b41c935e3f72a2b7b71b6c19b6860)
+++ src/google/protobuf/compiler/javamicro/javamicro_message_field.cc	(revision )
@@ -78,6 +78,14 @@
 MessageFieldGenerator::~MessageFieldGenerator() {}
 
 void MessageFieldGenerator::
+	GenerateToJSONCode(io::Printer* printer) const {
+  printer->Print(variables_,
+	"if (has$capitalized_name$()) {\n"
+	"  stringer.key(\"$name$\").value(get$capitalized_name$().toJSON());\n"
+	"}\n");
+}
+
+void MessageFieldGenerator::
 GenerateMembers(io::Printer* printer) const {
   printer->Print(variables_,
     "private boolean has$capitalized_name$;\n"
@@ -89,7 +97,8 @@
     "public $type$ get$capitalized_name$() { return $name$_; }\n"
     "public $message_name$ set$capitalized_name$($type$ value) {\n"
     "  if (value == null) {\n"
-    "    throw new NullPointerException();\n"
+//    "    throw new NullPointerException();\n"
+    "    return clear$capitalized_name$();"
     "  }\n"
     "  has$capitalized_name$ = true;\n"
     "  $name$_ = value;\n"
@@ -159,6 +168,19 @@
 RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
 
 void RepeatedMessageFieldGenerator::
+GenerateToJSONCode(io::Printer* printer) const {
+  printer->Print(variables_,
+	"count = get$capitalized_name$Count();\n"
+	"if (count > 0) {\n"
+	"  stringer.key(\"$name$\").array();\n"
+	"  for (int i = 0; i < count; ++i) {\n"
+	"    stringer.value(get$capitalized_name$(i).toJSON());\n"
+	"  }\n"
+	"  stringer.endArray();\n"
+	"}\n");
+}
+
+void RepeatedMessageFieldGenerator::
 GenerateMembers(io::Printer* printer) const {
   if (params_.java_use_vector()) {
     printer->Print(variables_,
@@ -172,14 +194,16 @@
       "}\n"
       "public $message_name$ set$capitalized_name$(int index, $type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.setElementAt(value, index);\n"
       "  return this;\n"
       "}\n"
       "public $message_name$ add$capitalized_name$($type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.addElement(value);\n"
       "  return this;\n"
@@ -201,14 +225,16 @@
       "}\n"
       "public $message_name$ set$capitalized_name$(int index, $type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  $name$_.set(index, value);\n"
       "  return this;\n"
       "}\n"
       "public $message_name$ add$capitalized_name$($type$ value) {\n"
       "  if (value == null) {\n"
-      "    throw new NullPointerException();\n"
+      //"    throw new NullPointerException();\n"
+      "    return this;\n"
       "  }\n"
       "  if ($name$_.isEmpty()) {\n"
       "    $name$_ = new java.util.ArrayList<$type$>();\n"
@@ -299,4 +325,4 @@
 }  // namespace javamicro
 }  // namespace compiler
 }  // namespace protobuf
-}  // namespace google
+}  // namespace google
\ No newline at end of file
Index: src/google/protobuf/compiler/javamicro/javamicro_message.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/google/protobuf/compiler/javamicro/javamicro_message.h	(revision ce2f59915e0b41c935e3f72a2b7b71b6c19b6860)
+++ src/google/protobuf/compiler/javamicro/javamicro_message.h	(revision )
@@ -78,6 +78,8 @@
   void GenerateClear(io::Printer* printer);
   void GenerateIsInitialized(io::Printer* printer);
 
+  void GenerateToJSONCode(io::Printer* printer);
+
   const Params& params_;
   const Descriptor* descriptor_;
   FieldGeneratorMap field_generators_;
@@ -90,4 +92,4 @@
 }  // namespace protobuf
 
 }  // namespace google
-#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
+#en
\ No newline at end of file
