1

I have this object value that is being returned and I would like to convert it into a useful JSON object that I can inspect and manipulate. Ultimately, my goal is to validate the values of username and accessKey. But 2 things are throwing me off. Double {{ makes it invalid JSON and sauce:options can't be converted into a property in a class because I can't create a class with a property called sauce:options.

{{
  "browserName": "MicrosoftEdge",
  "browserVersion": "latest",
  "platformName": "Windows 10",
  "sauce:options": {
    "username": "test",
    "accessKey": "123"
  }
}}

Here is what I tried:

string output = JsonConvert.SerializeObject(SauceSession.Options.ConfiguredEdgeOptions);

SauceSession.Options.ConfiguredEdgeOptions returns that object I mentioned above.

Got this back: Newtonsoft.Json.JsonSerializationException: 'Error getting value from 'BinaryLocation' on 'OpenQA.Selenium.Edge.EdgeOptions'.'

I also tried this:

var serialized = JsonConvert.SerializeObject(SauceSession.Options.ConfiguredEdgeOptions);

And got back this Newtonsoft.Json.JsonSerializationException: 'Error getting value from 'BinaryLocation' on 'OpenQA.Selenium.Edge.EdgeOptions'.'

Nikolay Advolodkin
  • 1,820
  • 2
  • 24
  • 28

0 Answers0