Read json.

@param <T>
the generic type
@param jsonStream
the json stream
@param clazz
the clazz
@return the t
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);
        }

    }
857556
public static <T> T fromJson(JsonNode json, Class<T> clazz, ClassLoader classLoader) {
        if (json == 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(json.toString(), 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);
        }
    }
1257157
public <T> T parse(String text, Class<T> clazz) {
        return gson.fromJson(text, clazz);
    }
469097
public static <T> T convertToObject(Class<T> clazz, InputStream inputStream) {
		return convertToObject(clazz, new InputStreamReader(inputStream));
	}
421128
public <T> JSONAPIDocument<T> readDocument(byte[] data, Class<T> clazz) {
		return readDocument(new ByteArrayInputStream(data), clazz);
	}
76226
public <T> T fromJson(@Nullable String jsonString, Class<T> clazz) {
		if (StringUtils.isEmpty(jsonString)) {
			return null;
		}

		try {
			return mapper.readValue(jsonString, clazz);
		} catch (IOException e) {
			logger.warn("parse json string error:" + jsonString, e);
			return null;
		}
	}
1206070
public <T extends KeyFile> T as(Class<T> clazz) {
		T result = GSON.fromJson(jsonObj, clazz);
		((KeyFile) result).jsonObj = jsonObj;
		return result;
	}
994525
public Object parse(InputStream inputStream) {
        if (inputStream == null) {
            throw new IllegalArgumentException("inputStream must not be null");
        }

        Object content;
        JsonParser parser = createParser();
        content = parser.parse(inputStream);
        return content;
    }
496961
protected String readJsonFrom(final InputStream json) throws IOException {
        return isJsonFormat()
            ? JsonValue.readHjson(IOUtils.toString(json, StandardCharsets.UTF_8)).toString()
            : String.join("\n", IOUtils.readLines(json, StandardCharsets.UTF_8));
    }
1032753
public <T> T parse(Reader in, JsonReaderI<T> mapper) throws ParseException {
		return getPStream().parse(in, mapper);
	}
1246550
protected <T> T readReadable(Class<T> clazz) throws IOException {
      try {
         T object = Reflect.onClass(clazz).allowPrivilegedAccess().create().get();
         JsonSerializable readable = Cast.as(object);
         boolean isArray = JsonArraySerializable.class.isAssignableFrom(clazz);//(object instanceof ArrayValue);
         if (isArray && peek() == JsonTokenType.BEGIN_ARRAY) {
            beginArray();
         } else if (peek() == JsonTokenType.BEGIN_OBJECT) {
            beginObject();
         }
         readable.fromJson(this);
         if (isArray && peek() == JsonTokenType.END_ARRAY) {
            endArray();
         } else if (peek() == JsonTokenType.END_OBJECT) {
            endObject();
         }
         return object;
      } catch (ReflectionException e) {
         throw new IOException(e);
      }
   }
294341
private <T> T read_(Class<T> clazz, Object id) {
		Map<String, Object> objects = objects(clazz);
		return (T) objects.get(id.toString());
	}
299033
public static <T> T withJsonInputStream(InputStream inputStream,
            Class<T> c) {
        try {
            return jsonMapper.readValue(inputStream, c);
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "withJsonInputStream", inputStream);
        }
    }
1203184
public <T> T read(final InputStream stream, final DataTypeDescriptor<T> descriptor) {
		try {
			return jsonFormat.read(stream, descriptor);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
415855
public static <T> T toObject(String json, Class<T> clazz) {
        if (json == null || json.trim().length() == 0) {
            return null;
        }
        T t = null;
        try {
            t = JSON.parseObject(json, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return t;
    }
1256076
public static <T> T readValue(InputStream inputStream, Class<T> type) throws IOException, BadVersionException {
        return DataModelSerializer.deserializeObject(inputStream, type);
    }
1155877
public static <T> T read(String key, Class<T> classOfT) throws Exception {

        String json = cache.getString(key).getString();
        T value = new Gson().fromJson(json, classOfT);
        if (value == null) {
            throw new NullPointerException();
        }
        return value;
    }