INNER CODE UNIT · Java
parse
alibaba/fastjson2 · core/src/main/java/com/alibaba/fastjson2/JSON.java:305
static Object parse(byte[] bytes, int offset, int length, Charset charset, JSONReader.Context context) {
if (bytes == null || bytes.length == 0) {
return null;
}
ObjectReader<?> objectReader = context.getObjectReader(Object.class);
try (JSONReader reader = JSONReader.of(bytes, offset, length, 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 char array as a {@link JSONArray} or {@link JSONObject}.