/// <summary> /// 获取名称索引 /// </summary> /// <param name="jsonDeSerializer">JSON 解析器</param> /// <param name="isQuote">名称是否带引号</param> /// <returns>名称索引,失败返回-1</returns> internal int SearchName(JsonDeSerializer jsonDeSerializer, out bool isQuote) { char value = jsonDeSerializer.GetFirstName(); if (State == null) { isQuote = jsonDeSerializer.Quote != 0; return(-1); } if (jsonDeSerializer.Quote != 0) { isQuote = true; return(searchString(jsonDeSerializer, value)); } isQuote = false; if (jsonDeSerializer.DeSerializeState != DeSerializeState.Success) { return(-1); } byte *currentState = State; do { char *prefix = (char *)(currentState + *(int *)currentState); if (*prefix != 0) { if (value != *prefix) { return(-1); } while (*++prefix != 0) { if (jsonDeSerializer.GetNextName() != *prefix) { return(-1); } } value = jsonDeSerializer.GetNextName(); } if (value == 0) { return(jsonDeSerializer.DeSerializeState == DeSerializeState.Success ? *(int *)(currentState + sizeof(int) * 2) : -1); } if (*(int *)(currentState + sizeof(int)) == 0) { return(-1); } int index = value < 128 ? (int)*(ushort *)(charsAscii + (value << 1)) : getCharIndex(value); byte *table = currentState + *(int *)(currentState + sizeof(int)); if (tableType == 0) { if ((index = *(table + index)) == 0) { return(-1); } currentState = State + index * 3 * sizeof(int); } else if (tableType == 1) { if ((index = (int)*(ushort *)(table + index * sizeof(ushort))) == 0) { return(-1); } currentState = State + index * 3 * sizeof(int); } else { if ((index = *(int *)(table + index * sizeof(int))) == 0) { return(-1); } currentState = State + index; } value = jsonDeSerializer.GetNextName(); }while (true); }