@Override
  public void encode(Object object, Type bodyType, RequestTemplate template)
      throws EncodeException {
    if (object == null) return;
    if (object instanceof JSONArray || object instanceof JSONObject) {
      template.body(object.toString());
    } else {
      throw new EncodeException(format("%s is not a type supported by this encoder.", bodyType));
    }
  }
Encodes requests using JSON-java.

<p>Basic example with {@link feign.Feign.Builder}:

<pre>
  interface GitHub {

    {@literal @}RequestLine("POST /repos/{owner}/{repo}/contributors")
    JSONObject create({@literal @}Param("owner") String owner,
                      {@literal @}@Param("repo") String repo,
                      JSONObject contributor);

  }

  GitHub github = Feign.builder()
                     .decoder(new JsonDecoder())
                     .encoder(new JsonEncoder())
                     .target(GitHub.class, "https://api.github.com");

  JSONObject contributor = new JSONObject();

  contributor.put("login", "radio-rogal");
  contributor.put("contributions", 0);
  github.create("openfeign", "feign", contributor);
</pre>
json/src/main/java/feign/json/JsonEncoder.java