File http-builder-0.7.2-no-json.patch of Package http-builder
diff -urEbwB httpbuilder-http-builder-0.7.2.orig/src/main/java/groovyx/net/http/EncoderRegistry.java httpbuilder-http-builder-0.7.2/src/main/java/groovyx/net/http/EncoderRegistry.java
--- httpbuilder-http-builder-0.7.2.orig/src/main/java/groovyx/net/http/EncoderRegistry.java 2024-10-04 17:12:20.173031380 +0200
+++ httpbuilder-http-builder-0.7.2/src/main/java/groovyx/net/http/EncoderRegistry.java 2024-10-04 18:04:14.570937980 +0200
@@ -44,11 +44,6 @@
import java.util.List;
import java.util.Map;
-import net.sf.json.JSON;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-import net.sf.json.groovy.JsonGroovyBuilder;
-
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.NameValuePair;
@@ -264,61 +259,6 @@
}
/**
- * <p>Accepts a Collection or a JavaBean object which is converted to JSON.
- * A Map or POJO/POGO will be converted to a {@link JSONObject}, and any
- * other collection type will be converted to a {@link JSONArray}. A
- * String or GString will be interpreted as valid JSON and passed directly
- * as the request body (with charset conversion if necessary.)</p>
- *
- * <p>If a Closure is passed as the model, it will be executed as if it were
- * a JSON object definition passed to a {@link JsonGroovyBuilder}. In order
- * for the closure to be interpreted correctly, there must be a 'root'
- * element immediately inside the closure. For example:</p>
- *
- * <pre>builder.post( JSON ) {
- * body = {
- * root {
- * first {
- * one = 1
- * two = '2'
- * }
- * second = 'some string'
- * }
- * }
- * }</pre>
- * <p> will return the following JSON string:<pre>
- * {"root":{"first":{"one":1,"two":"2"},"second":"some string"}}</pre></p>
- *
- * @param model data to be converted to JSON, as specified above.
- * @return an {@link HttpEntity} encapsulating this request data
- * @throws UnsupportedEncodingException
- */
- @SuppressWarnings("unchecked")
- public HttpEntity encodeJSON( Object model, Object contentType ) throws UnsupportedEncodingException {
-
- Object json;
- if ( model instanceof Map ) {
- json = new JSONObject();
- ((JSONObject)json).putAll( (Map)model );
- }
- else if ( model instanceof Collection ) {
- json = new JSONArray();
- ((JSONArray)json).addAll( (Collection)model );
- }
- else if ( model instanceof Closure ) {
- Closure closure = (Closure)model;
- closure.setDelegate( new JsonGroovyBuilder() );
- json = (JSON)closure.call();
- }
- else if ( model instanceof String || model instanceof GString )
- json = model; // assume string is valid JSON already.
- else json = JSONObject.fromObject( model ); // Assume object is a JavaBean
-
- if ( contentType == null ) contentType = ContentType.JSON;
- return this.createEntity( contentType, json.toString() );
- }
-
- /**
* Helper method used by encoder methods to create an {@link HttpEntity}
* instance that encapsulates the request data. This may be used by any
* non-streaming encoder that needs to send textual data. It also sets the
@@ -355,10 +295,6 @@
encoders.put( ct, encClosure );
encoders.put( ContentType.HTML.toString(), encClosure );
- encClosure = new MethodClosure(this,"encodeJSON");
- for ( String ct : ContentType.JSON.getContentTypeStrings() )
- encoders.put( ct, encClosure );
-
return encoders;
}