rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

@JsonString annotation not recognized on field of type List or Map #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?

1.10.3-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?

All

Describe the problem.

Try JSON parsing/generation on this class:

public class A {
    @Key
    @JsonString
    List<Long> longListValue;

    @Key
    @JsonString
    Map<String, Long> longMapValue;
}

and it will ignore the @JsonString annotation.  Sample stack trace:

java.lang.IllegalArgumentException: null: number field formatted as a JSON 
string must use the @JsonString annotation: null
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:613)
    at com.google.api.client.json.JsonParser.parseArray(JsonParser.java:459)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:525)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:357)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:563)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:296)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:273)
    at com.google.api.client.json.AbstractJsonFactoryTest.testParser_numberTypes(AbstractJsonFactoryTest.java:422)

How would you expect it to be fixed?

@JsonString annotation should be honored.

Original issue reported on code.google.com by yan...@google.com on 3 Aug 2012 at 7:26

GoogleCodeExporter commented 9 years ago
1.10: http://codereview.appspot.com/6457078/
1.11: http://codereview.appspot.com/6447088/

Original comment by yan...@google.com on 3 Aug 2012 at 8:29

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 3 Aug 2012 at 8:38