Reads JSON API spec document and converts it into target type.
@param data {@link byte} raw data (server response)
@param clazz {@link Class} target type
@param <T> type
@return {@link JSONAPIDocument}
421128
public <T> JSONAPIDocument<T> readDocument(byte[] data, Class<T> clazz) {
		return readDocument(new ByteArrayInputStream(data), clazz);
	}
1061972
public static <T extends XMLObject> T transformSamlObject(final OpenSamlConfigBean configBean, final byte[] data,
                                                              final Class<T> clazz) {
        try (InputStream in = new ByteArrayInputStream(data)) {
            val document = configBean.getParserPool().parse(in);
            val root = document.getDocumentElement();
            val marshaller = configBean.getUnmarshallerFactory().getUnmarshaller(root);
            if (marshaller != null) {
                val result = marshaller.unmarshall(root);
                if (!clazz.isAssignableFrom(result.getClass())) {
                    throw new ClassCastException("Result [" + result + " is of type " + result.getClass() + " when we were expecting " + clazz);
                }
                return (T) result;
            }
        } catch (final Exception e) {
            throw new SamlException(e.getMessage(), e);
        }
        return null;
    }
1183468
public static <T> T fromJson(final String json, final Class<T> clazz) {
        return fromJson(parse(json), clazz);
    }
525917
@Override
    public ODataEntity<?> readFrom(Class<ODataEntity<?>> type,
            Type genericType, Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
            throws IOException {

        ODataEntity<?> result = null;
        String responseType = mediaType.getParameters().get("type");
        try {
            if (responseType == null || responseType.equals("feed")) {
                List<ODataEntity<?>> feedContents = null;
                synchronized (unmarshaller) {
                    feedContents = unmarshaller.unmarshalFeed(entityStream,
                            type);
                }
                return feedContents.get(0);
            } else if (responseType.equals("entry")) {
                synchronized (unmarshaller) {
                    result = unmarshaller.unmarshalEntry(entityStream, type);
                }
            } else {
                throw new RuntimeException();
            }
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        } catch (ServiceException e) {
            throw new RuntimeException(e);
        }

        return result;
    }
1365317
public <T> T parseBody(Class<T> clazz) throws ParsableException, MediaTypeException {
        String contentType = request.getContentType();
        
        // if the content type header was not provided, we throw
        if (contentType == null || contentType.isEmpty()) {
            throw new MediaTypeException("Missing media type header");
        }
        
        // extract the actual content type in case charset is also a part of the string
        contentType = HttpHeaderUtil.getContentTypeFromContentTypeAndCharacterSetting(contentType);
        
        ParserEngine engine = parserEngineManager.getParserEngineForContentType(contentType);
        
        if (engine == null) {
            throw new MediaTypeException("An engine for media type ("+contentType+") was not found");
        }
        
        try {
            return engine.invoke(request.getInputStream(), clazz);
        } catch (IOException e) {
            throw new ParsableException(e);
        }
    }
335274
public static <T> T parseObject(String text, Class<T> clazz) {
        Object obj = JSONSerializer.deserialize(text);
        return BeanSerializer.deserializeByType(obj, clazz);
    }
346887
public static <T extends BaseBo> T fromJson(String json, Class<T> clazz) {
        return fromJson(json, clazz, null);
    }
440156
public <T> T getResponseBody(Class<T> clazz) {
        final ByteBuf byteBuf = httpInputMessage.getBody();
        if(byteBuf.readableBytes() == 0 || Void.class.isAssignableFrom(clazz)) return null;

        final MediaType mediaType = MediaType.parseMediaType(httpInputMessage.getHeaders().get(HttpHeaders.CONTENT_TYPE));
        for (HttpMessageConverter httpMessageConverter : httpMessageConverters) {
            if (httpMessageConverter.canRead(clazz, mediaType)) {
                return (T) httpMessageConverter.read(clazz, httpInputMessage);
            }
        }
        return null;
    }
896760
async function parseDocument(rawData) {
  try {
    const api = utils.unthrowableParseJson(rawData) || SwaggerParser.YAML.parse(rawData);
    if (!api) {
      return null;
    }

    // Await here so we catch any exceptions
    return await SwaggerParser.validate(api);
  } catch (err) {
    return null;
  }
}
659189
@Override
    public <T> T body(Class<T> classOfT, Type genericType) {
        String rawContentType = request().contentType();

        // If the Content-type: xxx header is not set we return null.
        // we cannot parse that request.
        if (rawContentType == null) {
            return null;
        }

        // If Content-type is application/json; charset=utf-8 we split away the charset
        // application/json
        String contentTypeOnly = HttpUtils.getContentTypeFromContentTypeAndCharacterSetting(
                rawContentType);

        BodyParser parser = services.getContentEngines().getBodyParserEngineForContentType(contentTypeOnly);

        if (parser == null) {
            return null;
        }

        return parser.invoke(this, classOfT, genericType);
    }
816851
@Override
    protected Document convertToObject(HTTPResponse httpResponse)
    {
        //get response text
        Document document=null;
        String content=httpResponse.getContent();
        if(content!=null)
        {
            //get response encoding
            String encoding=this.getResponseDataEncoding();

            //create in memory stream
            byte[] data=IOHelper.convertStringToBinary(content,encoding);
            InputStream inputStream=new ByteArrayInputStream(data);

            try
            {
                //parse XML
                DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
                DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
                document=documentBuilder.parse(inputStream);
            }
            catch(Exception exception)
            {
                throw new FaxException("Unable to parse HTTP response text as XML.",exception);
            }
            finally
            {
                //'close' stream
                IOHelper.closeResource(inputStream);
            }
        }
        
        return document;
    }
14888
public static <T extends MailChimpObject> T fromJson(String json, Class<T> clazz) {
		try {
			return MailChimpGsonFactory.createGson().fromJson(json, clazz);
		} catch(JsonParseException e) {
			throw new IllegalArgumentException(e);
		}
	}
932968
public static <T extends BasicMessage> T fromJSON(String json, Class<T> clazz) {
        try {
            Method buildObjectMapperForDeserializationMethod = findBuildObjectMapperForDeserializationMethod(clazz);

            final ObjectMapper mapper = (ObjectMapper) buildObjectMapperForDeserializationMethod.invoke(null);
            if (FailOnUnknownProperties.class.isAssignableFrom(clazz)) {
                mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
            }

            return mapper.readValue(json, clazz);
        } catch (Exception e) {
            throw new IllegalStateException("JSON message cannot be converted to object of type [" + clazz + "]", e);
        }
    }
1207791
public <T> T read (Class<T> type) throws YamlException {
		return read(type, null);
	}
650171
@SuppressWarnings("unchecked")
    public <T> T readAsObject(String content, Class<T> type) {
        Assert.notNull(type);
        try {
            if (StringUtils.isEmpty(content)) {
                log.debug("content为空，返回null", content, type);
                return null;
            } else if (type.equals(String.class)) {
                return (T) content;
            }
            return MAPPER.readValue(content, type);
        } catch (Exception e) {
            log.error("json解析失败，失败原因：", e);
            return null;
        }
    }
393859
public static <T> T fromByteArrayKryo(byte[] data, Class<T> clazz) {
        return fromByteArrayKryo(data, clazz, null);
    }
295337
@SuppressWarnings("unchecked")
    public static <T extends BaseBo> T fromBytes(byte[] bytes, Class<T> clazz,
            ClassLoader classLoader) {
        if (bytes == null || clazz == null) {
            return null;
        }
        try {
            Map<String, Object> data = SerializationUtils.fromByteArray(bytes, Map.class);
            String boClassName = DPathUtils.getValue(data, FIELD_CLASSNAME, String.class);
            T bo = createObject(boClassName, classLoader, clazz);
            if (bo != null) {
                bo.fromByteArray(DPathUtils.getValue(data, FIELD_BODATA, byte[].class));
                return bo;
            } else {
                return null;
            }
        } catch (Exception e) {
            throw e instanceof DeserializationException ? (DeserializationException) e
                    : new DeserializationException(e);
        }
    }