Deserialize a JSON string, with custom class loader.

@param jsonString
@param clazz
@return
543450
public static <T> T fromJsonString(String jsonString, Class<T> clazz, ClassLoader classLoader) {
        if (jsonString == null) {
            return null;
        }
        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        try {
            ObjectMapper mapper = poolMapper.borrowObject();
            if (mapper != null) {
                try {
                    return mapper.readValue(jsonString, clazz);
                } finally {
                    poolMapper.returnObject(mapper);
                }
            }
            throw new DeserializationException("No ObjectMapper instance avaialble!");
        } catch (Exception e) {
            throw e instanceof DeserializationException ? (DeserializationException) e
                    : new DeserializationException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    }
575084
public static Object fromJSON(String jsonString){
        List<Token> tokens = Derulo.toTokens(jsonString);
        return fromJSON(tokens);
    }
878570
public static Object fromJsonString(String jsonString, ClassLoader classLoader) {
        return fromJsonString(jsonString, Object.class, classLoader);
    }
848909
public <T> T deserialise(final Class<T> clazz, final String xml)
	{
		final Object obj = deserialise(new InputSource(new StringReader(xml)));

		if (clazz.isInstance(obj))
			return clazz.cast(obj);
		else
			throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + clazz);
	}
10302
public static <T> T loadJsonToBean(String jsonPath, Class<T> clazz) throws IOException {
        return loadJsonToBean(jsonPath, ValueConsts.NULL_STRING, clazz);
    }
459701
public T parse(String jsonString) throws IOException {
        JsonParser jsonParser = LoganSquare.JSON_FACTORY.createParser(jsonString);
        jsonParser.nextToken();
        return parse(jsonParser);
    }
822402
protected T readObjectFromString(final String jsonString) {
        try {
            LOGGER.trace("Attempting to consume [{}]", jsonString);
            return this.objectMapper.readValue(jsonString, getTypeToSerialize());
        } catch (final Exception e) {
            LOGGER.error("Cannot read/parse [{}] to deserialize into type [{}]. This may be caused "
                    + "in the absence of a configuration/support module that knows how to interpret the fragment, "
                    + "specially if the fragment describes a CAS registered service definition. "
                    + "Internal parsing error is [{}]",
                DigestUtils.abbreviate(jsonString), getTypeToSerialize(), e.getMessage());
            LOGGER.debug(e.getMessage(), e);
        }
        return null;
    }
588776
public static <E> E parse(String jsonString, Class<E> jsonObjectClass) throws IOException {
        return mapperFor(jsonObjectClass).parse(jsonString);
    }
873790
@SuppressWarnings("unchecked")
    public static <T> T fromByteArrayKryo(byte[] data, Class<T> clazz, ClassLoader classLoader) {
        if (data == null) {
            return null;
        }
        Kryo kryo = kryoPool.obtain();
        try {
            ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
            if (classLoader != null) {
                Thread.currentThread().setContextClassLoader(classLoader);
            }
            try {
                Input input = kryoInputPool.obtain();
                try {
                    kryo.setClassLoader(classLoader != null ? classLoader : oldClassLoader);
                    input.setInputStream(new ByteArrayInputStream(data));
                    Object obj = kryo.readClassAndObject(input);
                    input.close();
                    return obj != null && clazz.isAssignableFrom(obj.getClass()) ? (T) obj : null;
                } finally {
                    kryoInputPool.free(input);
                }
            } finally {
                Thread.currentThread().setContextClassLoader(oldClassLoader);
            }
        } finally {
            kryoPool.free(kryo);
        }
    }
763243
public final static <T> T readJson(InputStream jsonStream, Class<T> clazz)
    {
        ObjectMapper mapper = new ObjectMapper();
        try
        {
            if (jsonStream != null)
            {
                return mapper.readValue(jsonStream, clazz);
            }
            else
            {
                LOGGER.error("InputStream is null.");
                throw new KunderaException("InputStream is null.");
            }
        }
        catch (IOException e)
        {
            LOGGER.error("Error while mapping input stream to object. Caused By: ", e);
            throw new KunderaException("Error while mapping input stream to object. Caused By: ", e);
        }

    }
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);
		}
	}
584784
public static String toJsonString(Object obj, ClassLoader classLoader) {
        if (obj == null) {
            return "null";
        }
        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        try {
            ObjectMapper mapper = poolMapper.borrowObject();
            if (mapper != null) {
                try {
                    return mapper.writeValueAsString(obj);
                } finally {
                    poolMapper.returnObject(mapper);
                }
            }
            throw new SerializationException("No ObjectMapper instance avaialble!");
        } catch (Exception e) {
            throw e instanceof SerializationException ? (SerializationException) e
                    : new SerializationException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    }
1157629
public <T> T deserialise(final Class<T> clazz, final InputSource source)
	{
		final Object obj = deserialise(source);

		if (clazz.isInstance(obj))
			return clazz.cast(obj);
		else
			throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + clazz);
	}
191512
@Nullable
    public static Card fromString(@NonNull String jsonString) {
        try {
            JSONObject jsonObject = new JSONObject(jsonString);
            return fromJson(jsonObject);
        } catch (JSONException ignored) {
            return null;
        }
    }
335274
public static <T> T parseObject(String text, Class<T> clazz) {
        Object obj = JSONSerializer.deserialize(text);
        return BeanSerializer.deserializeByType(obj, clazz);
    }
997280
<T> T deserialize(String body, Class<T> clazz) {
        if (body == null || body.isEmpty()) {
            throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR,
                    ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR.getMessageTemplate(),
                    "the message body is empty");
        }

        try {
            return JsonSerializer.deserialize(body.getBytes(), clazz);
        } catch (Exception e) {
            throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, e,
                    ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR.getMessageTemplate(),
                    "unrecognized message, deserialize failed.");
        }
    }
45147
public static <E> Map<String, E> parseMap(String jsonString, Class<E> jsonObjectClass) throws IOException {
        return mapperFor(jsonObjectClass).parseMap(jsonString);
    }