简体   繁体   中英

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. I have to send messages in Json format, that line is what I'm sending and this is the error I'm getting:

{"error":{"code":-32700,"message":"Parse error.","data":["Message should be in JSON format."]},"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:

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. 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. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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