private static int ParseFieldName(int i, string recordString, ODocument document)
        {
            int startIndex = i;

            // iterate until colon is found since it's the character which ends the field name
            while (recordString[i] != ':')
            {
                i++;

                if (i >= recordString.Length)
                {
                    return(recordString.Length);
                }
            }

            // parse field name string from raw document string
            string fieldName = recordString.Substring(startIndex, i - startIndex);

            document.Add(fieldName, null);

            // move to position after colon (:)
            i++;

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return(i);
            }

            // check what follows after parsed field name and start parsing underlying type
            switch (recordString[i])
            {
            case '"':
                i = ParseString(i, recordString, document, fieldName);
                break;

            case '#':
                i = ParseRecordID(i, recordString, document, fieldName);
                break;

            case '(':
                i = ParseEmbeddedDocument(i, recordString, document, fieldName);
                break;

            case '[':
                i = ParseList(i, recordString, document, fieldName);
                break;

            case '<':
                i = ParseSet(i, recordString, document, fieldName);
                break;

            case '{':
                i = ParseMap(i, recordString, document, fieldName);
                break;

            default:
                i = ParseValue(i, recordString, document, fieldName);
                break;
            }

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return(i);
            }

            // single string value was parsed and we need to push the index if next character is comma
            if (recordString[i] == ',')
            {
                i++;
            }

            return(i);
        }
        private int ParseFieldName(int i, string recordString, ODocument document)
        {
            int startIndex = i;

            int iColonPos = recordString.IndexOf(':', i);

            if (iColonPos == -1)
            {
                return(recordString.Length);
            }

            i = iColonPos;

            // parse field name string from raw document string
            string fieldName = recordString.Substring(startIndex, i - startIndex);
            int    pos       = fieldName.IndexOf('@');

            if (pos > 0)
            {
                fieldName = fieldName.Substring(pos + 1, fieldName.Length - pos - 1);
            }

            fieldName = fieldName.Replace("\"", "");

            document.Add(fieldName, null);

            // move to position after colon (:)
            i++;

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return(i);
            }

            // check what follows after parsed field name and start parsing underlying type
            switch (recordString[i])
            {
            case '"':
                i = ParseString(i, recordString, document, fieldName);
                break;

            case '#':
                i = ParseRecordID(i, recordString, document, fieldName);
                break;

            case '(':
                i = ParseEmbeddedDocument(i, recordString, document, fieldName);
                break;

            case '[':
                i = ParseList(i, recordString, document, fieldName);
                break;

            case '<':
                i = ParseSet(i, recordString, document, fieldName);
                break;

            case '{':
                i = ParseEmbeddedDocument(i, recordString, document, fieldName);
                break;

            case '%':
                i = ParseRidBags(i, recordString, document, fieldName);
                break;

            default:
                i = ParseValue(i, recordString, document, fieldName);
                break;
            }

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return(i);
            }

            // single string value was parsed and we need to push the index if next character is comma
            if (recordString[i] == ',')
            {
                i++;
            }

            return(i);
        }
        private static int ParseFieldName(int i, string recordString, ODocument document)
        {
            int startIndex = i;

            // iterate until colon is found since it's the character which ends the field name
            while (recordString[i] != ':')
            {
                i++;

                if (i >= recordString.Length)
                {
                    return recordString.Length;
                }
            }

            // parse field name string from raw document string
            string fieldName = recordString.Substring(startIndex, i - startIndex);
            int pos = fieldName.IndexOf('@');
            if (pos > 0)
            {
                fieldName = fieldName.Substring(pos + 1, fieldName.Length - pos - 1);
            }

            fieldName = fieldName.Replace("\"", "");

            document.Add(fieldName, null);

            // move to position after colon (:)
            i++;

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return i;
            }

            // check what follows after parsed field name and start parsing underlying type
            switch (recordString[i])
            {
                case '"':
                    i = ParseString(i, recordString, document, fieldName);
                    break;
                case '#':
                    i = ParseRecordID(i, recordString, document, fieldName);
                    break;
                case '(':
                    i = ParseEmbeddedDocument(i, recordString, document, fieldName);
                    break;
                case '[':
                    i = ParseList(i, recordString, document, fieldName);
                    break;
                case '<':
                    i = ParseSet(i, recordString, document, fieldName);
                    break;
                case '{':
                    i = ParseMap(i, recordString, document, fieldName);
                    break;
                case '%':
                    i = ParseRidBags(i, recordString, document, fieldName);
                    break;
                default:
                    i = ParseValue(i, recordString, document, fieldName);
                    break;
            }

            // check if it's not the end of document which means that current field has null value
            if (i == recordString.Length)
            {
                return i;
            }

            // single string value was parsed and we need to push the index if next character is comma
            if (recordString[i] == ',')
            {
                i++;
            }

            return i;
        }