简体   繁体   English

找不到格式错误

[英]Can't find formatting error

What's wrong with this: 这有什么问题:

String json = "{ \"id\" : \"1\",\"method\" : \"Page.navigate\",\"params\" : { \"url\" : \"http://gmail.com\" }}";

UPDATE : 更新

I'm trying to use the google chrome remote debugging feature. 我正在尝试使用Google chrome远程调试功能。 I have to send messages in Json format, that line is what I'm sending and this is the error I'm getting: 我必须以Json格式发送消息,这是我要发送的行,这是我收到的错误:

{"error":{"code":-32700,"message":"Parse error.","data":["Message should be in JSON format."]},"id":null} {“错误”:{“代码”:-32700,“消息”:“解析错误。”,“数据”:[“消息应采用JSON格式。”]},“ id”:null}

Many of the problems I have encountered regarding JSON strings in C# has been as a result of escape characters getting formatted improperly, To be safe, I do: 对于C#中的JSON字符串,我遇到的许多问题都是由于转义字符的格式不正确造成的,为了安全起见,我这样做:

String json = @"{ \"id\" : \"1\",\"method\" : \"Page.navigate\",\"params\" : [{ \"url\" : \"http://gmail.com\" }]}";

That may not solve all of your problems but it helped me a lot. 那可能无法解决您所有的问题,但对我有很大帮助。

Also, when working with JSON, I find using fiddler2 is helpful at capturing the packets and seeing what you're doing wrong at that level. 另外,在使用JSON时,我发现使用fiddler2有助于捕获数据包并查看您在该级别上做错了什么。 You can get it from here . 你可以从这里得到。 You can also use Fiddler2's "Composer" feature to test JSON posts without using MVS, let me know if you need more information on how to use it. 您还可以在不使用MVS的情况下使用Fiddler2的“ Composer”功能测试JSON帖子,如果您需要更多有关如何使用它的信息,请告诉我。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM