@SuppressWarnings("unchecked") public static <T> T parseObject(byte[] input, // int off, // int len, // CharsetDecoder charsetDecoder, // Type clazz, // Feature... features) { charsetDecoder.reset(); int scaleLength = (int) (len * (double) charsetDecoder.maxCharsPerByte()); char[] chars = allocateChars(scaleLength); ByteBuffer byteBuf = ByteBuffer.wrap(input, off, len); CharBuffer charByte = CharBuffer.wrap(chars); IOUtils.decode(charsetDecoder, byteBuf, charByte); int position = charByte.position(); return (T) parseObject(chars, position, clazz, features); }
public static Object parse(byte[] input, Feature... features) { char[] chars = allocateChars(input.length); int len = IOUtils.decodeUTF8(input, 0, input.length, chars); if (len < 0) { return null; } return parse(new String(chars, 0, len), features); }
/** * @since 1.2.55 */ @SuppressWarnings("unchecked") public static <T> T parseObject(byte[] bytes, int offset, int len, Charset charset, Type clazz, ParserConfig config, ParseProcess processor, int featureValues, Feature... features) { if (charset == null) { charset = IOUtils.UTF8; } String strVal; if (charset == IOUtils.UTF8) { char[] chars = allocateChars(bytes.length); int chars_len = IOUtils.decodeUTF8(bytes, offset, len, chars); if (chars_len < 0) { return null; } strVal = new String(chars, 0, chars_len); } else { if (len < 0) { return null; } strVal = new String(bytes, offset, len, charset); } return (T) parseObject(strVal, clazz, config, processor, featureValues, features); }
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features) { charsetDecoder.reset(); int scaleLength = (int) (len * (double) charsetDecoder.maxCharsPerByte()); char[] chars = allocateChars(scaleLength); ByteBuffer byteBuf = ByteBuffer.wrap(input, off, len); CharBuffer charBuf = CharBuffer.wrap(chars); IOUtils.decode(charsetDecoder, byteBuf, charBuf); int position = charBuf.position(); DefaultJSONParser parser = new DefaultJSONParser(chars, position, ParserConfig.getGlobalInstance(), features); Object value = parser.parse(); parser.handleResovleTask(value); parser.close(); return value; }