Class JsonLocation
Represents the location of a specific JSON value within a root JSON value.
Inheritance
Implements
Inherited Members
Namespace: JsonCons.JsonPath
Assembly: JsonCons.JsonPath.dll
Syntax
public sealed class JsonLocation : IEquatable<JsonLocation>, IComparable<JsonLocation>, IEnumerable<JsonLocationNode>, IEnumerable
Constructors
| Improve this Doc View SourceJsonLocation(JsonLocationNode)
Constructs a normalized path from the last location node.
Declaration
public JsonLocation(JsonLocationNode lastNode)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonLocationNode | lastNode |
Properties
| Improve this Doc View SourceLast
Gets the last node of the JsonLocation.
Declaration
public JsonLocationNode Last { get; }
Property Value
| Type | Description |
|---|---|
| JsonLocationNode |
Methods
| Improve this Doc View SourceCompareTo(JsonLocation)
Compares this instance with a specified JsonLocation object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified JsonLocation.
Declaration
public int CompareTo(JsonLocation other)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonLocation | other | The JsonLocation to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Int32 | A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as other. |
ContainsValue(JsonElement)
Looks for a value within the root value that matches this normalized path, returning true if such a value exists, false otherwise.
Declaration
public bool ContainsValue(JsonElement root)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Text.Json.JsonElement | root | The root value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the value was found, false otherwise. |
Equals(JsonLocation)
Determines whether this instance and another specified JsonLocation object have the same value.
Declaration
public bool Equals(JsonLocation other)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonLocation | other | The JsonLocation to compare to this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the value of other is the same as the value of this instance; otherwise, false. If other is null, the method returns false. |
Equals(Object)
Determines whether this instance and a specified object, which must also be a JsonLocation object, have the same value.
Declaration
public override bool Equals(object other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | other | The JsonLocation to compare to this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if other is a JsonLocation and its value is the same as this instance; otherwise, false. If other is null, the method returns false. |
Overrides
GetEnumerator()
Returns an enumerator that iterates through the components of the normalized path.
Declaration
public IEnumerator<JsonLocationNode> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<JsonLocationNode> |
GetHashCode()
Returns the hash code for this JsonLocation.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A 32-bit signed integer hash code. |
Overrides
ToJsonPointer()
Gets a JSON Pointer representation for the normalized path. The string will have the form /aName/anotherName/anIndex with any '~' and '/' characters appearing in names escaped as per the specification.
Declaration
public string ToJsonPointer()
Returns
| Type | Description |
|---|---|
| System.String |
ToString()
Gets a string representation for the normalized path. The string will have the form $['aName']['anotherName'][anIndex] with any single quote characters appearing in names escaped with a backslash.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
TryGetValue(JsonElement, out JsonElement)
Looks for a value within the root value that matches this normalized path, returning
true if such a value exists, false otherwise. When the value exists element
is assigned that value.
Declaration
public bool TryGetValue(JsonElement root, out JsonElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Text.Json.JsonElement | root | The root value. |
| System.Text.Json.JsonElement | element | Receives the value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the value was found, false otherwise. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |