Miguel
Miguel

Reputation: 134

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}

Upvotes: 0

Views: 145

Answers (1)

ScruffMcGruff
ScruffMcGruff

Reputation: 168

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.

Upvotes: 1

Related Questions