1

我在使用 JayRock 时遇到问题,我间歇性地收到缺失值错误。

我无法重新创建错误,但它每天在生产中发生大约 100-150 次(在数万个请求中)。

经过调查发现,在失败的请求中,HTTP 请求中没有 [RequestBody] 元素。

通常它看起来像这样:

[网址]

[RequestBody] {"id":1,"method":"getAllAirports","params":[]}

[饼干]

但在它没有工作的情况下,请求包含:

[网址]

[饼干]

我正在使用默认的 JayRock 代理,并且通过使用 ?test 页面,请求始终有效。

有没有人遇到过这个?或者有什么想法?

非常感谢,

伊恩

更新:查看数据,它似乎完全是 IE 中的错误,在 IE7、8、9 和 10 中都有错误。尽管 8 的错误最多,尽管它的流量与 9 相当,但小于 10。

4

1 回答 1

0

似乎是来自 Jayrock http://jayrock.googlecode.com/hg/src/Jayrock.Json/Json/JsonTextReader.cs的解析问题

private JsonToken Parse()
    {
        char ch = NextClean();

        //
        // String
        //

        if (ch == '"' || ch == '\'')
        {
            return Yield(JsonToken.String(NextString(ch)));
        }

        //
        // Object
        //

        if (ch == '{')
        {
            _reader.Back();
            return ParseObject();
        }

        //
        // Array
        //

        if (ch == '[')
        {
            _reader.Back();
            return ParseArray();
        }

        //
        // Handle unquoted text. This could be the values true, false, or
        // null, or it can be a number. An implementation (such as this one)
        // is allowed to also accept non-standard forms.
        //
        // Accumulate characters until we reach the end of the text or a
        // formatting character.
        // 

        StringBuilder sb = new StringBuilder();
        char b = ch;

        while (ch >= ' ' && ",:]}/\\\"[{;=#".IndexOf(ch) < 0) 
        {
            sb.Append(ch);
            ch = _reader.Next();
        }

        _reader.Back();

        string s = sb.ToString().Trim();

        if (s.Length == 0)
            throw SyntaxError("Missing value.");


        //
        // Boolean
        //

        if (s == JsonBoolean.TrueText || s == JsonBoolean.FalseText)
            return Yield(JsonToken.Boolean(s == JsonBoolean.TrueText));

        //
        // Null
        //

        if (s == JsonNull.Text)
            return Yield(JsonToken.Null());

        //
        // Number
        //
        // Try converting it. We support the 0- and 0x- conventions. 
        // If a number cannot be produced, then the value will just
        // be a string. Note that the 0-, 0x-, plus, and implied 
        // string conventions are non-standard, but a JSON text parser 
        // is free to accept non-JSON text forms as long as it accepts 
        // all correct JSON text forms.
        //

        if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+')
        {
            if (b == '0' && s.Length > 1 && s.IndexOfAny(_numNonDigitChars) < 0)
            {
                if (s.Length > 2 && (s[1] == 'x' || s[1] == 'X'))
                {
                    string parsed = TryParseHex(s);
                    if (!ReferenceEquals(parsed, s))
                        return Yield(JsonToken.Number(parsed));
                }
                else
                {
                    string parsed = TryParseOctal(s);
                    if (!ReferenceEquals(parsed, s))
                        return Yield(JsonToken.Number(parsed));
                }
            }
            else
            {
                if (!JsonNumber.IsValid(s))
                    throw SyntaxError(string.Format("The text '{0}' has the incorrect syntax for a number.", s));

                return Yield(JsonToken.Number(s));
            }
        }

        //
        // Treat as String in all other cases, e.g. when unquoted.
        //

        return Yield(JsonToken.String(s));
    }
于 2013-10-24T14:40:42.287 回答