src/main/java/com/rockagen/commons/util/JsonUtil.java
public static <T> T toBean(JsonParser jsonParser, Class<T> clazz) {
		if (clazz == null || jsonParser == null)
			return null;

		T obj = null;
		try {
			obj = getMapper().readValue(jsonParser, clazz);
		} catch (JsonParseException e) {
			log.error("{}", e.getMessage(), e);
		} catch (JsonMappingException e) {
			log.error("{}", e.getMessage(), e);
		} catch (IOException e) {
			log.error("{}", e.getMessage(), e);
		} finally {
			try {
				jsonParser.close();
			} catch (IOException e) {
			}
		}
		return obj;

	}
public static <T> T toBean(JsonParser jsonParser, Class<T> clazz) {
		if (clazz == null || jsonParser == null)
			return null;

		T obj = null;
		try {
			obj = getMapper().readValue(jsonParser, clazz);
		} catch (JsonParseException e) {
			log.error("{}", e.getMessage(), e);
		} catch (JsonMappingException e) {
			log.error("{}", e.getMessage(), e);
		} catch (IOException e) {
			log.error("{}", e.getMessage(), e);
		} finally {
			try {
				jsonParser.close();
			} catch (IOException e) {
			}
		}
		return obj;

	}
public static < T > T toBean ( JsonParser jsonParser , Class < T > clazz ) { if ( clazz == null || jsonParser == null ) return null ; T obj = null ; try { obj = getMapper ( ) . readValue ( jsonParser , clazz ) ; } catch ( JsonParseException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( JsonMappingException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( IOException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } finally { try { jsonParser . close ( ) ; } catch ( IOException e ) { } } return obj ; }
Json string to java bean <br>
<p>
e.g:
</p>
<pre>
{"id" : idValue, "name" : nameValue, "aBean" : {"aBeanId" : aBeanIdValue, ...}}
</pre>
<p>
List,Array,Map... see {@link #toBean(String, TypeReference)}
</p>

@param jsonParser json parser
@param clazz class
@param <T> t
@return bean
Json string to java bean <br > <p > e . g : < / p > <pre > { id : idValue name : nameValue aBean : { aBeanId : aBeanIdValue ... }} < / pre > <p > List Array Map ... see { @link #toBean ( String TypeReference ) } < / p >