mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 14:13:02 +02:00
PartialMapping : SimMetrics.Net
This commit is contained in:
@@ -8,7 +8,7 @@ namespace WireMock.Matchers
|
||||
/// <summary>
|
||||
/// JSONPathMatcher
|
||||
/// </summary>
|
||||
/// <seealso cref="WireMock.Matchers.IMatcher" />
|
||||
/// <seealso cref="IMatcher" />
|
||||
public class JsonPathMatcher : IMatcher
|
||||
{
|
||||
private readonly string _pattern;
|
||||
@@ -27,25 +27,23 @@ namespace WireMock.Matchers
|
||||
/// <summary>
|
||||
/// Determines whether the specified input is match.
|
||||
/// </summary>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the specified input is match; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool IsMatch(string input)
|
||||
/// <param name="input">The input string</param>
|
||||
/// <returns>A value between 0.0 - 1.0 of the similarity.</returns>
|
||||
public double IsMatch(string input)
|
||||
{
|
||||
if (input == null)
|
||||
return false;
|
||||
return MatchScores.Mismatch;
|
||||
|
||||
try
|
||||
{
|
||||
JObject o = JObject.Parse(input);
|
||||
JToken token = o.SelectToken(_pattern);
|
||||
|
||||
return token != null;
|
||||
return MatchScores.ToScore(token != null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
return MatchScores.Mismatch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,5 +55,14 @@ namespace WireMock.Matchers
|
||||
{
|
||||
return _pattern;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <returns>Name</returns>
|
||||
public string GetName()
|
||||
{
|
||||
return "JsonPathMatcher";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user