2012-08-29 383 views
1

我下面的JSON字符串:JSON.NET解析錯誤

{ 
    "message": "Keine Nachricht mit der Id 55555 gefunden!", 
    "exception": { 
    "__className": "Exception" 
    }, 
    "request": { 
    "__className": "Zend_Controller_Request_Http" 
    } 
} 

JObject.Parse()將拋出我這個錯誤:

"Additional text encountered after finished reading JSON content: . Path '', line 1, position 153." 

什麼是錯的這個JSON字符串?

+0

json字符串末尾是否有空格或字符? – Erwin

+2

沒有......... –

+0

最後有控制字符。對不起是我的錯誤。 –

回答

0

它在Ruby中解析我。該字符串(當它是一個長行)是152個字符,所以之後可能有一個字符。

0

下面的應用程序的工作原理:

class Program 
{ 
    static void Main(string[] args) 
    { 
     var x = 
      @"{""message"": ""Keine Nachricht mit der Id 55555 gefunden!"",""exception"": {""__className"": ""Exception""},""request"": {""__className"": ""Zend_Controller_Request_Http""}}"; 

     var y = JObject.Parse(x); 
    } 
} 

檢查以確保字符串你認爲你傳遞給解析()確實看起來像上面的字符串。