Json.Serialization.JsonFormatter.GetValueString C# (CSharp) Method

GetValueString() private method

Extracts a value from a given string
private GetValueString ( string s, int &pos ) : string
s string string to be parsed
pos int start position
return string
        private string GetValueString(string s, ref int pos)
        {
            int nq = s.IndexOf('\"', pos);
            int nn = s.IndexOf(NullString, pos);
            if (nn > 0 && nn < nq) return null;
            int nsp = s.IndexOf(':', pos);
            if (nsp != -1)
            {
                //pos = nsp + 2;
                pos = nsp + 1;
            }
            
            int nt = s.IndexOfAny(new char[] { '}', ',' }, pos);
            if (nt < nq || (nq == -1 && nt != -1))
            {
                string rv = s.Substring(pos, nt - pos);
                pos = nt + 1;
                return rv;
            }
            
            return GetNextQuotedString(s, ref pos);
        }