org.bbqjs.spring.http.converter.json
Class UrlEncodedMappingJacksonHttpMessageConverter

java.lang.Object
  extended by org.springframework.http.converter.AbstractHttpMessageConverter<Object>
      extended by org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
          extended by org.bbqjs.spring.http.converter.json.UrlEncodedMappingJacksonHttpMessageConverter
All Implemented Interfaces:
org.springframework.http.converter.HttpMessageConverter<Object>

public class UrlEncodedMappingJacksonHttpMessageConverter
extends org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

Extends the MappingJacksonHttpMessageConverter to de-encode all Strings passed to the server as JSON objects. For example, the string " must be encoded to be part of a JSON object:


 { foo: """ }
 
Would become:

 { foo: "%22" }
 
This class automatically runs every String through URLDecoder#decode as part of mapping from JSON to a POJO. For this to work every string field must have a POJO style getter and setter method associated with it. So, for example:

 public class Foo {
     private String bar;
 
     public void setBar(String bar) {
         this.bar = bar;
     }
 
     public String getBar() {
         return bar;
     }
 }
 
N.B. unless you manually URLEncode your strings on the client side, using this class should not be necessary.

Author:
alex

Field Summary
 
Fields inherited from class org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
DEFAULT_CHARSET
 
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
 
Constructor Summary
UrlEncodedMappingJacksonHttpMessageConverter()
           
 
Method Summary
protected  Object readInternal(Class<?> clazz, org.springframework.http.HttpInputMessage inputMessage)
           
 
Methods inherited from class org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
canRead, canWrite, getJavaType, setObjectMapper, setPrefixJson, supports, writeInternal
 
Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
canRead, canWrite, getContentLength, getDefaultContentType, getSupportedMediaTypes, read, setSupportedMediaTypes, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlEncodedMappingJacksonHttpMessageConverter

public UrlEncodedMappingJacksonHttpMessageConverter()
Method Detail

readInternal

protected Object readInternal(Class<?> clazz,
                              org.springframework.http.HttpInputMessage inputMessage)
                       throws IOException,
                              org.springframework.http.converter.HttpMessageNotReadableException
Overrides:
readInternal in class org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
Throws:
IOException
org.springframework.http.converter.HttpMessageNotReadableException


Copyright © 2012. All Rights Reserved.