{"action":"created","issue":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/333","labels_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/333/comments","events_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/333/events","html_url":"https://github.com/chrsmith/google-api-java-client/issues/333","id":59381907,"number":333,"title":"Ability to stream parse a feed of entries","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Component-JSON","name":"Component-JSON","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Priority-High","name":"Priority-High","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Type-Enhancement","name":"Type-Enhancement","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-03-01T05:50:41Z","updated_at":"2015-03-01T05:50:44Z","closed_at":null,"body":"```\nExternal references, such as a standards document, or specification?\n\nn/a\n\nJava environments (e.g. Java 6, Android 2.3, App Engine, or All)?\n\nAll, but particularly relevant for low-memory devices like Android\n\nPlease describe the feature requested.\n\nWe need an ability in the generated service-specific libraries to parse a feed \nof entries as a stream, without having to load the whole feed into memory which \nmay cause an OutOfMemoryError on low-memory devices.\n\nHere is a code snippet that Alon Albert wrote that demonstrates one possible \nway this can be accomplished today:\n\n          while (true) {\n                final JsonParser parser = JsonHttpParser.parserForResponse(jsonFactory, response);\n                parser.nextToken();\n                JsonToken token = parser.getCurrentToken();\n                String nextPageToken = null;\n                while (token == JsonToken.FIELD_NAME) {\n                    String key = parser.getText();\n                    parser.nextToken();\n                    if (key.equals(\"nextPageToken\")) {\n                        nextPageToken = parser.parse(String.class, null);\n                    } else if (key.equals(\"items\")) {\n                        while (true) {\n                            // skip START_ARRAY/END_OBJECT\n                            parser.nextToken();\n                            if (parser.getCurrentToken() == JsonToken.END_ARRAY) {\n                                break;\n                            }\n                            final Entry entry = parser.parse(Entry.class, null);\n                            System.out.println(entry);\n                        }\n                    } else {\n\n                        parser.skipChildren();\n                    }\n                    token = parser.nextToken();\n                }\n                if (nextPageToken == null) {\n                    break;\n                }\n                response = builder.setPageToken(nextPageToken).executeUnparsed();\n            }\n\nIdeally we would add support that would support the that Alon needs here, but \nthat wouldn't require him to write any JsonParser low-level parsing code.\n\nI tried to implement something like this long ago with JsonFeedParser:\n\nhttp://javadoc.google-api-java-client.googlecode.com/hg/1.5.1-beta/com/google/ap\ni/client/googleapis/json/JsonFeedParser.html\n\nbut for various reasons that doesn't do what we want.  So either we fix up \nJsonFeedParser to work better, or try a different approach.  For example, we \ncould try Iterator<Entry> for accessing the entries, though keep in mind we \nstill need the ability the ability to parse the feed metadata.\n\nFinally, we need to integrate this into the generated service-specific \nlibraries, so this is easy to use and discover.\n```\n\nOriginal issue reported on code.google.com by `yan...@google.com` on 28 Oct 2011 at 8:16"},"comment":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/comments/76576686","html_url":"https://github.com/chrsmith/google-api-java-client/issues/333#issuecomment-76576686","issue_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/333","id":76576686,"user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"created_at":"2015-03-01T05:50:44Z","updated_at":"2015-03-01T05:50:44Z","body":"\n\nOriginal comment by `yan...@google.com` on 27 Sep 2013 at 12:00\n* Removed labels: **Milestone-Version1.18.0**"}}