@Override protected JsonFactory newJsonFactoryInstance() { return new JacksonFactory(); } }
static JsonFactory newJsonFactory() { return new JacksonFactory(); }
@Override protected JsonFactory newJsonFactoryInstance() { return new JacksonFactory(); }
public JacksonObjectPersisterFactory(Application application, List<Class<?>> listHandledClasses) throws CacheCreationException { super(application, new JacksonFactory(), listHandledClasses); }
public JacksonObjectPersisterFactory(Application application, List<Class<?>> listHandledClasses, File cacheFolder) throws CacheCreationException { super(application, new JacksonFactory(), listHandledClasses, cacheFolder); }
@Override protected JsonFactory newJsonFactoryInstance() { return new JacksonFactory(); }
public JacksonObjectPersisterFactory(Application application) throws CacheCreationException { super(application, new JacksonFactory()); }
static JsonFactory newJsonFactory() { return new JacksonFactory(); }
static JsonFactory newJsonFactory() { return new JacksonFactory(); }
public JacksonObjectPersisterFactory(Application application, File cacheFolder) throws CacheCreationException { super(application, new JacksonFactory(), cacheFolder); }
@Provides @Singleton JsonFactory provideJsonFactory() { return new JacksonFactory(); }
public static <T> String parseDoubanObjToJSONStr(T obj) throws IOException { JsonHttpContent content = new JsonHttpContent(new JacksonFactory(), obj); ByteArrayOutputStream os = new ByteArrayOutputStream(); content.writeTo(os); String result = new String(os.toByteArray()); return result; }
/** * Uses basic authentication to create an HTTP request factory. * * @return HttpRequestFactory */ public HttpRequestFactory getRequestFactory() { if (this.requestFactory == null) { this.requestFactory = HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setParser(new JsonObjectParser(new JacksonFactory())); request.getHeaders().setBasicAuthentication(getUsername(), getPassword()); } }); } return this.requestFactory; }
private static void parseJson () { try { DoubanShuoAttachementObj att = generateAtt(); JsonHttpContent content = new JsonHttpContent(new JacksonFactory(), att); ByteArrayOutputStream os = new ByteArrayOutputStream(); content.writeTo(os); String result = new String(os.toByteArray()); System.out.println("result ! : " + result); System.out.println("getdate : " + (String)content.getData()); } catch (IOException ex) { Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public void initialize(HttpRequest request) throws IOException { credential.initialize(request); request.setParser(new JsonObjectParser(new JacksonFactory())); } });
/** * Attempts to get credentials from Google Compute Engine. * * @return valid credentials or {@code null} */ public static Credential getComputeEngineCredential() throws GeneralSecurityException, IOException { NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport(); try { // Try to connect using Google Compute Engine service account credentials. ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory()); // Force token refresh to detect if we are running on Google Compute Engine. credential.refreshToken(); return credential; } catch (IOException e) { return null; } }
public <T extends IDoubanObject> T getResponseInJson(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException { if (params != null && params.size() > 0) { String encodedParams = encodeParameters(params); url = url + "?" + encodedParams; } HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url)); method.setParser(new JsonObjectParser(new JacksonFactory())); return httpRequest(method, needAccessToken).parseAs(responseType); }
public <T> T getResponseInJsonArray(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException { if (params != null && params.size() > 0) { String encodedParams = encodeParameters(params); url = url + "?" + encodedParams; } HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url)); method.setParser(new JsonObjectParser(new JacksonFactory())); return httpRequest(method, needAccessToken).parseAs(responseType); }
@Override public void initialize(HttpRequest request) throws IOException { request.setParser(new JsonObjectParser(new JacksonFactory())); request.getHeaders().setBasicAuthentication(getUsername(), getPassword()); } });
public <T, W extends IDoubanObject> W postResponseInJson(String url, T requestObj, Class<W> responseType, boolean needAccessToken) throws DoubanException, IOException { AtomContent content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj); HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content); method.setParser(new JsonObjectParser(new JacksonFactory())); return httpRequest(method, needAccessToken).parseAs(responseType); }