Open wimdeblauwe opened 6 years ago
The JSON API is pretty limited right now, so I don't think you have many options there.
Are there plans to add support for Jsonpath (https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm) ?
No. My focus is mostly on the main library. But we're open to PRs 😉
This is my 2nd day doing .NET development, so a PR is a bit of a stretch for now :-)
But I managed to get what I needed manually like this:
JToken.Parse(json).Should().HaveCount(2);
JToken.Parse(json).SelectToken("$[0]").Value<string>().Should().Be("value1");
JToken.Parse(json).SelectToken("$[1]").Value<string>().Should().Be("value2");
or:
JToken.Parse(json).SelectTokens("$").Values<string>().Should()
.HaveCount(2)
.And.Equal("value1", "value2");
I am trying out fluentassertions.json and I wonder how I can assert values in a json array. Suppose I have a controller that returns:
And the following test:
So far, so good. Now I would like to write something like this:
Is there a way to do this?