Comments (4)
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.
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.
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.
Original comment by [email protected]
on 2 Jun 2011 at 6:45
- Changed state: Fixed
from google-http-java-client.
Related Issues (20)
- HttpResponse.parseAs() accepts Void.class to ignore HOT 13
- Upgrade to latest version of protobuf (2.4.1) HOT 5
- HttpParser/ObjectParser should support Type and InputStream HOT 5
- Add a HttpHeaders.fromHttpHeaders(..) method HOT 1
- Better error message from FieldInfo.setFieldValue HOT 1
- NetHttpTransport drops Content-Length header when posting 0-length data HOT 4
- CloseGuard error after EOFException HOT 23
- UriTemplate COMPOSITE_PREFIXES init problem HOT 4
- UriTemplate.expand should support Iterable<?> for list parameters HOT 3
- User-agent repeatedly added on retry HOT 3
- Error when building the last development branch HOT 2
- IOException is thrown by following code. HOT 3
- ClassCastException in ApacheHttpRequest.setContent HOT 2
- protobuf installation instructions HOT 2
- ObjectGenerator HOT 3
- Can no longer create UrlFetchTransport since GAE SDK 1.6.6 HOT 4
- ExponentialBackOffPolicy is broken HOT 1
- Document JSON enum parsing HOT 1
- OSGI Support HOT 10
- HttpRequest should not log the Authorization-header in batched requests HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-http-java-client.