public boolean parse(byte[] data, int offset, int len, Listener listener) {
        byte state = STATE_BEGIN;
        boolean escape = false;
        boolean couldBeString = false;
        int valueType = 0;
        valueBuffer.clear();
        int objectOffset = 0;

        int to = offset + len;
        int pos = offset;
        for (; pos < to; pos++) {
            byte b = data[pos];
            switch (state) {
                case STATE_BEGIN:
                    switch (b) {
                        case BLANK:
                            break;
                        case CURLY_BRACE_LEFT:
                            state = STATE_NEXT_KEY;
                            objectOffset = pos;
                            listener.onStartJson(objectOffset);
                            break;
                        default:
                            logErrorJson("expecting {", data, offset, len, pos);
                            return false;
                    }
                    break;
                case STATE_NEXT_KEY:
                    switch (b) {
                        case BLANK:
                            break;
                        case DOUBLE_QUOTE:
                            valueBuffer.clear();
                            state = STATE_IN_KEY;
                            break;
                        case CURLY_BRACE_RIGHT:
                            state = STATE_FINISH;
                            listener.onFinishJson(objectOffset, pos - objectOffset + 1);
                            break;
                        default:
                            logErrorJson("expecting \" or }", data, offset, len, pos);
                            return false;
                    }
                    break;
                case STATE_IN_KEY:
                    switch (b) {
                        case BACKSLASH:
                            if (escape) {
                                valueBuffer.put(b);
                                escape = false;
                            } else {
                                escape = true;
                            }
                            break;
                        case DOUBLE_QUOTE:
                            if (escape) {
                                valueBuffer.put(b);
                                escape = false;
                            } else {
                                valueBuffer.flip();
                                state = STATE_KEY_FINISH;
                                valueType = listener.onKey(valueBuffer, valueBuffer.limit());
                            }
                            break;
                        default:
                            if (escape) {
                                logErrorJson("illegal character after", data, offset, len, pos);
                                return false;
                            } else {
                                valueBuffer.put(b);
                            }
                            break;
                    }
                    break;
                case STATE_KEY_FINISH:
                    switch (b) {
                        case BLANK:
                            break;
                        case COLON:
                            state = STATE_NEXT_VALUE;
                            break;
                        default:
                            logErrorJson("expecting :", data, offset, len, pos);
                            return false;
                    }
                    break;
                case STATE_NEXT_VALUE:
                    switch (b) {
                        case BLANK:
                            break;
                        case DOUBLE_QUOTE:
                            valueBuffer.clear();
                            couldBeString = true;
                            // Enable {"number": "100"}
                            //if (isNumber(valueType)) {
                            //    logErrorJson("expecting number", data, offset, len, pos);
                            //    return false;
                            //}
                            state = STATE_IN_VALUE;
                            break;
                        case CURLY_BRACE_LEFT:
                            logErrorJson("multi-layer is not supported", data, offset, len, pos);
                            return false;
                        default:
                            valueBuffer.clear();
                            valueBuffer.put(b);
                            couldBeString = false;
                            state = STATE_IN_VALUE;
                            break;
                    }
                    break;
                case STATE_IN_VALUE:
                    switch (b) {
                        case BACKSLASH:
                            if (escape) {
                                valueBuffer.put(b);
                                escape = false;
                            } else {
                                escape = true;
                            }
                            break;
                        case DOUBLE_QUOTE:
                            if (escape) {
                                valueBuffer.put(b);
                                escape = false;
                            } else {
                                valueBuffer.flip();
                                state = STATE_VALUE_FINISH;
                                if (valueType == INVALID) {
                                    // Do nothing.
                                } else if (isNumber(valueType)) {
                                    if (!onNumber(valueType, valueBuffer, listener)) {
                                        logErrorJson("illegal number", data, offset, len, pos - valueBuffer.limit());
                                        return false;
                                    }
                                } else {
                                    if (!listener.onStringValue(valueBuffer, valueBuffer.remaining())) {
                                        logErrorJson("illegal string", data, offset, len, pos - valueBuffer.limit());
                                        return false;
                                    }
                                }
                            }
                            break;
                        case COMMA:
                            if (escape) {
                                logErrorJson("illegal character", data, offset, len, pos);
                                return false;
                            } else {
                                if (valueType == INVALID) {
                                    if (couldBeString) {
                                        valueBuffer.put(b);
                                    } else {
                                        state = STATE_NEXT_KEY;
                                    }
                                } else if (isNumber(valueType)) {
                                    valueBuffer.flip();
                                    state = STATE_NEXT_KEY;
                                    if (!onNumber(valueType, valueBuffer, listener)) {
                                        logErrorJson("not a number", data, offset, len, pos - valueBuffer.limit());
                                        return false;
                                    }
                                } else {
                                    valueBuffer.put(b);
                                }
                            }
                            break;
                        case CURLY_BRACE_RIGHT:
                            if (escape) {
                                logErrorJson("illegal character", data, offset, len, pos);
                                return false;
                            } else {
                                if (valueType == INVALID) {
                                    if (couldBeString) {
                                        valueBuffer.put(b);
                                    } else {
                                        state = STATE_FINISH;
                                        listener.onFinishJson(objectOffset, pos - objectOffset + 1);
                                    }
                                } else if (isNumber(valueType)) {
                                    valueBuffer.flip();
                                    state = STATE_FINISH;
                                    if (!onNumber(valueType, valueBuffer, listener)) {
                                        logErrorJson("not a number", data, offset, len, pos - valueBuffer.limit());
                                        return false;
                                    }
                                    listener.onFinishJson(objectOffset, pos - objectOffset + 1);
                                } else {
                                    valueBuffer.put(b);
                                }
                            }
                            break;
                        default:
                            if (escape) {
                                logErrorJson("illegal character", data, offset, len, pos);
                                return false;
                            } else {
                                valueBuffer.put(b);
                            }
                            break;
                    }
                    break;
                case STATE_VALUE_FINISH:
                    switch (b) {
                        case BLANK:
                            break;
                        case COMMA:
                            state = STATE_NEXT_KEY;
                            break;
                        case CURLY_BRACE_RIGHT:
                            state = STATE_FINISH;
                            listener.onFinishJson(objectOffset, pos - objectOffset + 1);
                            break;
                        default:
                            logErrorJson("expecting ,", data, offset, len, pos);
                            return false;
                    }
                    break;
                case STATE_FINISH:
                    switch (b) {
                        case BLANK:
                            break;
                        case COMMA:
                            state = STATE_BEGIN;
                            break;
                        default:
                            logErrorJson("expecting EOF", data, offset, len, pos);
                            return false;
                    }
                    break;
                default:
                    logErrorJson("illegal state: " + state, data, offset, len, pos);
                    return false;
            }
        }
        if (state != STATE_FINISH) {
            logErrorJson("incomplete json", data, offset, len, pos);
            return false;
        }
        return true;
    }
A fast json deserializer which parse json in utf-8 encoding bytes directly.
Using this class to avoid the pay-off of transforming into utf-16 (i.e. java String), and generating lots of intermediate objects.
It supports multiple json objects, seperated by comma, and each object can only contains one layer. e.g.
<pre>
{"name": "Flow", "score": 4.3}, {"title": "You know \"nothing\"! Jon Snow."}
</pre>
indexr-common/src/main/java/io/indexr/util/UTF8JsonDeserializer.java