All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.stripe.net.JsonEncoder Maven / Gradle / Ivy

There is a newer version: 28.2.0
Show newest version
package com.stripe.net;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

final class JsonEncoder {
  private static final Gson BODY_GSON =
      new GsonBuilder()
          .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
          .serializeNulls()
          .create();

  public static HttpContent createHttpContent(Map params) throws IOException {
    if (params == null) {
      params = new HashMap();
    }
    return HttpContent.buildJsonContent(BODY_GSON.toJson(params));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy