json数据转化成实体的方法

public static  T parse(String str,Class value) throws POAException
	{
		try {
			if(jsonGenerator == null)
			{
				jsonGenerator = objectMapper.getJsonFactory().createJsonGenerator(System.out, JsonEncoding.UTF8);
			}
			T result = objectMapper.readValue(str, value);
			return result;
		} catch (JsonParseException e) {
			e.printStackTrace();
			throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
		} catch (JsonMappingException e) {
			e.printStackTrace();
			throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
		} catch (IOException e) {
			e.printStackTrace();
			throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
		}
	}

你可能感兴趣的:(json数据转化成实体的方法)