Home JsonPointer Class
JsonPointer Class
Cancel

JsonPointer Class

Namespace: Json.Pointer

Inheritance: JsonPointer 🡒 object

Implemented interfaces:

  • IEquatable<JsonPointer>
  • IReadOnlyList<string>
  • IReadOnlyCollection<string>
  • IEnumerable<string>
  • IEnumerable

Represents a JSON Pointer IAW RFC 6901.

Fields

NameTypeSummary
EmptyJsonPointerThe empty pointer.

Properties

NameTypeSummary
CountintGets the number of segments in the pointer.
ItemstringGets a segment value by index.
ItemJsonPointerCreates a new pointer with the indicated segments.

Methods

Combine(JsonPointer other)

Concatenates a pointer onto the current pointer.

Declaration

1
public JsonPointer Combine(JsonPointer other)
ParameterTypeDescription
otherJsonPointerAnother pointer.

Returns

A new pointer.

Combine(params PointerSegment[] additionalSegments)

Concatenates additional segments onto the current pointer.

Declaration

1
public JsonPointer Combine(params PointerSegment[] additionalSegments)
ParameterTypeDescription
additionalSegmentsparams PointerSegment[]The additional segments.

Returns

A new pointer.

Create(params PointerSegment[] segments)

Creates a new JSON Pointer from a collection of segments.

Declaration

1
public static JsonPointer Create(params PointerSegment[] segments)
ParameterTypeDescription
segmentsparams PointerSegment[]A collection of segments.

Returns

The JSON Pointer.

Remarks

This method creates un-encoded pointers only.

Create(Expression<Func<T, object>> expression, PointerCreationOptions options)

Generates a JSON Pointer from a lambda expression.

Declaration

1
public static JsonPointer Create(Expression<Func<T, object>> expression, PointerCreationOptions options)
ParameterTypeDescription
expressionExpression<Func<T, object>>The lambda expression which gives the pointer path.
optionsPointerCreationOptions(optional) Options for creating the pointer.

Returns

The JSON Pointer.

Equals(JsonPointer other)

Indicates whether the current object is equal to another object of the same type.

Declaration

1
public bool Equals(JsonPointer other)
ParameterTypeDescription
otherJsonPointerAn object to compare with this object.

Returns

true if the current object is equal to theother parameter; otherwise, false.

Equals(object obj)

Indicates whether this instance and a specified object are equal.

Declaration

1
public override bool Equals(object obj)
ParameterTypeDescription
objobjectThe object to compare with the current instance.

Returns

true ifobj and this instance are the same type and represent the same value; otherwise, false.

Evaluate(JsonElement root)

Evaluates the pointer over a System.Text.Json.JsonElement.

Declaration

1
public JsonElement? Evaluate(JsonElement root)
ParameterTypeDescription
rootJsonElementThe System.Text.Json.JsonElement.

Returns

The sub-element at the pointer’s location, or null if the path does not exist.

GetAncestor(int levels)

Creates a new pointer retaining the starting segments.

Declaration

1
public JsonPointer GetAncestor(int levels)
ParameterTypeDescription
levelsintHow many levels to remove from the end of the pointer.

Returns

A new pointer.

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration

1
public IEnumerator<string> GetEnumerator()

Returns

An enumerator that can be used to iterate through the collection.

GetHashCode()

Returns the hash code for this instance.

Declaration

1
public override int GetHashCode()

Returns

A 32-bit signed integer that is the hash code for this instance.

GetLocal(int levels)

Creates a new pointer retaining the ending segments.

Declaration

1
public JsonPointer GetLocal(int levels)
ParameterTypeDescription
levelsintHow many levels to keep from the end of the pointer.

Returns

A new pointer.

GetSubPointer(Range range)

Creates a new pointer with the indicated segments.

Declaration

1
public JsonPointer GetSubPointer(Range range)
ParameterTypeDescription
rangeRangeThe segment range for the new pointer.

Returns

A new pointer.

Parse(string source)

Parses a JSON Pointer from a string.

Declaration

1
public static JsonPointer Parse(string source)
ParameterTypeDescription
sourcestringThe source string.

Returns

A JSON Pointer.

ToString()

Returns the string representation of this instance.

Declaration

1
public override string ToString()

Returns

The string representation.

TryEvaluate(JsonNode root, out JsonNode result)

Evaluates the pointer over a System.Text.Json.Nodes.JsonNode.

Declaration

1
public bool TryEvaluate(JsonNode root, out JsonNode result)
ParameterTypeDescription
rootJsonNodeThe System.Text.Json.Nodes.JsonNode.
resultout JsonNodeThe result, if return value is true; null otherwise

Returns

true if a value exists at the indicate path; false otherwise.

TryParse(string source, out JsonPointer pointer)

Parses a JSON Pointer from a string.

Declaration

1
public static bool TryParse(string source, out JsonPointer pointer)
ParameterTypeDescription
sourcestringThe source string.
pointerout JsonPointerThe resulting pointer.

Returns

true if the parse was successful; false otherwise.

Contents