Class GsonObjectParser

  • All Implemented Interfaces:
    com.google.api.client.util.ObjectParser

    public class GsonObjectParser
    extends Object
    implements com.google.api.client.util.ObjectParser

    ObjectParser implementation to be used along with google-http-client backed by Gson.

    The default implementation doesn't work at all for some reason, and I'm not sure either why the whole json parsing was re-invented in the http-client instead of just delegating it to the underlying framework.

    I'm just going to assume Google engineers are way smarter than me but it's just that I don't know how to use the in-built new JsonObjectParser(new GsonFactory).

    • Constructor Detail

      • GsonObjectParser

        public GsonObjectParser​(com.google.gson.Gson gson)
    • Method Detail

      • parseAndClose

        public <T> T parseAndClose​(InputStream in,
                                   Charset charset,
                                   Class<T> dataClass)
                            throws IOException
        Specified by:
        parseAndClose in interface com.google.api.client.util.ObjectParser
        Throws:
        IOException
      • parseAndClose

        public <T> T parseAndClose​(Reader reader,
                                   Class<T> dataClass)
                            throws IOException
        Specified by:
        parseAndClose in interface com.google.api.client.util.ObjectParser
        Throws:
        IOException
      • parseAndClose

        public Object parseAndClose​(Reader reader,
                                    Type dataType)
                             throws IOException
        Specified by:
        parseAndClose in interface com.google.api.client.util.ObjectParser
        Throws:
        IOException