public ApiClient setDateFormat(DateFormat dateFormat) { this.json.setDateFormat(dateFormat); return this; }
public ApiClient setDateTimeFormat(DateTimeFormatter dateFormat) { this.json.setDateTimeFormat(dateFormat); return this; }
public ApiClient setLenientOnJson(boolean lenientOnJson) { this.json.setLenientOnJson(lenientOnJson); return this; }
/** * Format the given parameter object into string. * * @param param Parameter * @return String representation of the parameter */ public String parameterToString(Object param) { if (param == null) { return ""; } else if (param instanceof Date || param instanceof DateTime || param instanceof LocalDate) { //Serialize to json string and remove the " enclosing characters String jsonStr = json.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); for (Object o : (Collection)param) { if (b.length() > 0) { b.append(","); } b.append(String.valueOf(o)); } return b.toString(); } else { return String.valueOf(param); } }
@Test public void testSerializeByteArray() { final JSON json = new JSON(); final String plainText = "string that contains '=' when encoded"; final String base64String = json.serialize(plainText.getBytes()); //serialize returns string surrounded by quotes: "\"[base64]\"" final String pureString = base64String.replaceAll("^\"|\"$", ""); final ByteString byteStr = ByteString.decodeBase64(pureString); //Check encoded to valid base64 assertNotNull(byteStr); //Check encoded string correctly final String decodedText = new String(byteStr.toByteArray()); assertThat(decodedText, is(plainText)); } }
public Response<T> next() { try { String line = response.source().readUtf8Line(); if (line == null) { throw new RuntimeException("Null response from the server."); } try { return json.deserialize(line, watchType); } catch (JsonParseException ex) { Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new Response<T>(status.type, status.object); } } catch (IOException e) { throw new RuntimeException("IO Exception during next method.", e); } }
public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true; json = new JSON(); // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0-SNAPSHOT/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("BearerToken", new ApiKeyAuth("header", "authorization")); authentications.put("BasicAuth", new HttpBasicAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
public ApiClient setSqlDateFormat(DateFormat dateFormat) { this.json.setSqlDateFormat(dateFormat); return this; }
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { this.json.setLocalDateFormat(dateFormat); return this; }
client .getJSON() .getGson() .fromJson(json, Class.forName("io.kubernetes.client.models." + args[1])); String output = client.getJSON().getGson().toJson(obj); client .getJSON() .getGson() .fromJson( new StringReader(output), Class.forName("io.kubernetes.client.models." + args[1])); String output2 = client.getJSON().getGson().toJson(obj2);
/** * Format the given parameter object into string. * * @param param Parameter * @return String representation of the parameter */ public String parameterToString(Object param) { if (param == null) { return ""; } else if (param instanceof Date || param instanceof DateTime || param instanceof LocalDate) { //Serialize to json string and remove the " enclosing characters String jsonStr = json.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); for (Object o : (Collection)param) { if (b.length() > 0) { b.append(","); } b.append(String.valueOf(o)); } return b.toString(); } else { return String.valueOf(param); } }
public Response<T> next() { try { String line = response.source().readUtf8Line(); if (line == null) { throw new RuntimeException("Null response from the server."); } try { return json.deserialize(line, watchType); } catch (JsonParseException ex) { Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new Response<T>(status.type, status.object); } } catch (IOException e) { throw new RuntimeException("IO Exception during next method.", e); } }
public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true; json = new JSON(); // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0-SNAPSHOT/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("BearerToken", new ApiKeyAuth("header", "authorization")); authentications.put("BasicAuth", new HttpBasicAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
public ApiClient setSqlDateFormat(DateFormat dateFormat) { this.json.setSqlDateFormat(dateFormat); return this; }
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { this.json.setLocalDateFormat(dateFormat); return this; }
/** * Serialize the given Java object into request body according to the object's * class and the request Content-Type. * * @param obj The Java object * @param contentType The request Content-Type * @return The serialized request body * @throws ApiException If fail to serialize the given object */ public RequestBody serialize(Object obj, String contentType) throws ApiException { if (obj instanceof byte[]) { // Binary (byte array) body parameter support. return RequestBody.create(MediaType.parse(contentType), (byte[]) obj); } else if (obj instanceof File) { // File body parameter support. return RequestBody.create(MediaType.parse(contentType), (File) obj); } else if (isJsonMime(contentType)) { String content; if (obj != null) { content = json.serialize(obj); } else { content = null; } return RequestBody.create(MediaType.parse(contentType), content); } else { throw new ApiException("Content type \"" + contentType + "\" is not supported"); } }
V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1;
public ApiClient setDateTimeFormat(DateTimeFormatter dateFormat) { this.json.setDateTimeFormat(dateFormat); return this; }
public ApiClient setDateFormat(DateFormat dateFormat) { this.json.setDateFormat(dateFormat); return this; }
public ApiClient setLenientOnJson(boolean lenientOnJson) { this.json.setLenientOnJson(lenientOnJson); return this; }