Phoenixasuga / google-api-java-client

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

JSON response could not be deserialized to Sqlresponse.class #545

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.5.0-beta)?
google-api-services-fusiontables-v1-rev1-1.7.2-beta.zip

Java environment (e.g. Java 6, Android 2.3, App Engine)?
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) Client VM (build 20.8-b03, mixed mode, sharing)

Describe the problem.
Can't deserialize 'Sqlresponse'. Try this code to reproduce the error:

JsonFactory jsonFactory = new JacksonFactory();

        com.google.api.client.json.JsonParser parser = jsonFactory.createJsonParser("{\n" +
                "    \"kind\": \"fusiontables#sqlresponse\",\n" +
                "    \"columns\": [\n" +
                "        \"rowid\"\n" +
                "    ],\n" +
                "    \"rows\": [\n" +
                "        [\n" +
                "            \"2801\"\n" +
                "        ],\n" +
                "        [\n" +
                "            \"2802\"\n" +
                "        ]\n" +
                "    ]\n" +
                "}");

        parser.parse(Sqlresponse.class, null);

How would you expect it to be fixed?
I have attached a modified version of Sqlresponse. With this version I was able 
to deserialize all JSON responses from the API.

The error was caused by the setRows and getRows method:

java.util.List<java.util.List<java.util.List<Object>>> rows

must be

java.util.List<java.util.List<Object>> rows

Original issue reported on code.google.com by christ...@christianjunk.de on 30 Jun 2012 at 12:32

Attachments:

GoogleCodeExporter commented 9 years ago

The fusion tables discovery doc is here: 
https://www.googleapis.com/discovery/v1/apis/fusiontables/v1/rest

The part we are interested is:
"rows": {
     "type": "array",
     "description": "The rows in the table. For each cell we print out whatever cell value (e.g., numeric, string) exists. Thus it is important that each cell contains only one value.",
     "items": {
      "type": "array",
      "items": {
       "type": "array",
       "items": {
        "type": "any"
       }
      }
     }
    }

Original comment by rmis...@google.com on 9 Jul 2012 at 5:19

GoogleCodeExporter commented 9 years ago
For

"rows": {
     "type": "array",
     "description": "The rows in the table. For each cell we print out whatever cell value (e.g., numeric, string) exists. Thus it is important that each cell contains only one value.",
     "items": {
      "type": "array",
      "items": {
       "type": "array",
       "items": {
        "type": "any"
       }
      }
     }
    }

Generating java.util.List<java.util.List<java.util.List<Object>>> rows looks 
correct.

Maybe the discovery doc is out of sync with the server. Also, as Tony observed 
there is no reason for a triply nested array to represent a table.

Warren, can you please take a look at this? There seems to be a mismatch 
between https://www.googleapis.com/discovery/v1/apis/fusiontables/v1/rest and 
what the server is returning.

Original comment by rmis...@google.com on 9 Jul 2012 at 5:38

GoogleCodeExporter commented 9 years ago
I will look into it.  My hunch is that in a cell value in a row may contain 
either atomic values such as numbers and strings, or a geometry value which may 
contain an array of points, lines or polygons.  The generated client library 
may not be handling this mixture gracefully.

Original comment by whs...@google.com on 9 Jul 2012 at 6:03

GoogleCodeExporter commented 9 years ago
Based on my reading of this, the JSON schema seems incorrect to me.  See:
http://tools.ietf.org/html/draft-zyp-json-schema-03

It needs to be declared like this:

"rows": {
     "type": "array",
     "description": "The rows in the table. For each cell we print out whatever cell value (e.g., numeric, string) exists. Thus it is important that each cell contains only one value.",
     "items": {
      "type": "array",
      "items": {
       "type": "any",
      }
     }
    }

If so, then let's close this issue as "ByDesign" and file a bug internally to 
fix the JSON Schema.

By the way, thanks to the original reporter for the feedback!

Original comment by yan...@google.com on 9 Jul 2012 at 6:41

GoogleCodeExporter commented 9 years ago
A bug has now been filed internally to track this issue.  Thanks for the report.

Original comment by whs...@google.com on 9 Jul 2012 at 6:47

GoogleCodeExporter commented 9 years ago
Thank you!

Original comment by christ...@christianjunk.de on 9 Jul 2012 at 8:25

GoogleCodeExporter commented 9 years ago
Closing this issue as "ByDesign" since the internal bug is filed.

Original comment by rmis...@google.com on 10 Jul 2012 at 11:28

GoogleCodeExporter commented 9 years ago
Any workaround till this is solved?

Original comment by deepakjh...@gmail.com on 12 Aug 2012 at 6:34

GoogleCodeExporter commented 9 years ago
A fix for this issue should go live very soon.  Until then, you can use the 
modified version of Sqlresponse.java posted by the originator of this thread.

Original comment by whs...@google.com on 13 Aug 2012 at 5:01

GoogleCodeExporter commented 9 years ago
Hello,

Is this fixed in v1-rev19-1.14.1-beta? I'm asking because I'm still getting the 
Exception thrown from the example:

https://code.google.com/p/google-api-java-client/source/browse?repo=samples#hg%2
Ffusiontables-cmdline-sample

Regards,
Alex

Original comment by dev.alej...@gmail.com on 8 May 2013 at 8:08