/// <summary> /// Creates a new <see cref="JsonPath"/> object which starts by specifying an object property. /// </summary> /// <param name="name">The name to follow.</param> /// <returns>A new <see cref="JsonPath"/>.</returns> /// <remarks>If <paramref name="name"/> is "length", operates as <see cref="Length()"/></remarks> public static JsonPath Name(string name = null) { var path = new JsonPath(); switch (name) { case null: path.Operators.Add(WildCardOperator.Instance); break; case "length": path.Operators.Add(LengthOperator.Instance); break; default: path.Operators.Add(new NameOperator(name)); break; } return(path); }
/// <summary> /// Appends a <see cref="JsonPath"/> by specifying an object property. /// </summary> /// <param name="path">The <see cref="JsonPath"/> to extend.</param> /// <param name="name">The name to follow.</param> /// <returns>The new <see cref="JsonPath"/>.</returns> /// <remarks>If <paramref name="name"/> is "length", operates as <see cref="Length(JsonPath)"/></remarks> public static JsonPath Name(this JsonPath path, string name = null) { var newPath = new JsonPath(); newPath.Operators.AddRange(path.Operators); switch (name) { case null: newPath.Operators.Add(WildCardOperator.Instance); break; case "length": newPath.Operators.Add(LengthOperator.Instance); break; default: newPath.Operators.Add(new NameOperator(name)); break; } return(newPath); }
internal JsonPathSyntaxException(JsonPath path, string message) : base(message) { Path = path.ToString(); }