Git Product home page Git Product logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
The easiest fix might be to allow:

  Item[] parsed = reponse.parseAs(Item[].class).

The parseAsArray -- or maybe more accurately List<T> parseAsList(Class<T> 
listItemClass) -- is a reasonable option.  But it would be nice to avoid 
introducing a new method to the HttpParser interface.

The response.parseInto(items) where items is a List<Item> won't work due to 
Java erasure, which means that the JSON parser will see something like 
List<Object> and therefore parse the response incorrectly.  I wish Java allowed 
List<String>.class :)

We should also fix the IllegalArgumentException to make the error message more 
understandable.

By the way, until this is fixed, as a work-around, you should be able to simply 
call JsonParser.parseArrayAndClose on the HttpResponse.

Original comment by [email protected] on 23 May 2011 at 11:38

from google-http-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
As the original reporter, I can confirm that the work around of calling 
parseArrayAndClose on the HttpResponse works as I had expected.

I do like the parseAs(Item[].class) suggestion as a means to keep the method 
count down and consistent with parsing non-array HttpResponse

Original comment by [email protected] on 24 May 2011 at 1:53

from google-http-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
http://codereview.appspot.com/4528115/

Original comment by [email protected] on 1 Jun 2011 at 8:14

  • Changed state: Started

from google-http-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024

Original comment by [email protected] on 2 Jun 2011 at 6:45

  • Changed state: Fixed

from google-http-java-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.