It seems to work fine for me, except that I had to make a change to
convert field names with underscores into camel case. I've attached a
diff below.
Thanks,
Abhishek
92,98c92
< /**
< * Name of the field could be in the form abc_def_ghi,
which would be the name
< * declared in the proto file. However, the generated
code in Java for this field
< * would be in camel case with the name abcDefGhi. So,
we must transform field
< * names here to camel case before setting them inside
the generated Java class.
< */
< String fieldName = toCamelCase(name) + "_";
---
> String fieldName = name + "_";
107c101
<
---
>
144,183d137
<
< /**
< * Converts {@code in} to camel case with first character of the
string left as is. For example,
< * "hello" -> "hello", "abc_def" -> "abcDef".
< * @param in is the input string
< * @return camel case output.
< */
< private static String toCamelCase(final String in) {
< final String[] pieces = in.split("_");
< if (pieces.length <= 1) {
< return in;
< }
< final ArrayList<String> list = new ArrayList<String>();
< list.add(pieces[0]);
< for (int i = 1; i < pieces.length; ++i) {
< String piece = pieces[i];
< if (piece.length() > 0) {
< char[] ch = piece.toCharArray();
< ch[0] = Character.toUpperCase(ch[0]);
< list.add(new String(ch));
< }
< }
< return joinStrings(list, "");
< }
< /**
< * Joins list of Strings using the given delimiter.
< * @param list to join
< * @param delimiter to use
< * @return comma separated list of Strings
< */
< private static String joinStrings(final List<String> list, final
String delimiter) {
< String out = new String();
< for (final String str : list) {
< if (false == out.isEmpty()) {
< out += delimiter;
< }
< out += str;
< }
< return out;
> --
> You received this message because you are subscribed to the Google Groups
> "google-gson" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
google-gson...@googlegroups.com.
> To post to this group, send email to
googl...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/google-gson?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>