INNER CODE UNIT · Java
parse
alibaba/fastjson2 · core/src/main/java/com/alibaba/fastjson2/JSON.java:442
static Object parse(InputStream in, Charset charset, JSONReader.Context context) {
if (in == null) {
return null;
}
ObjectReader<?> objectReader = context.getObjectReader(Object.class);
try (JSONReader reader = JSONReader.of(in, charset, context)) {
Object object = objectReader.readObject(reader, null, null, 0);
if (reader.ch != EOI && (context.features & IgnoreCheckClose.mask) == 0) {
throw new JSONException(reader.info("input not end"));
}
return object;
}
}
/**
* Parses the json string as a {@link JSONObject}. Returns {@code null}
* if received {@link String} is {@code null} or empty or its content is null.