Class JsonExtensions
- Namespace
- ActivityPub.Types.Internal
- Assembly
- ActivityPub.Types.dll
internal static class JsonExtensions
- Inheritance
-
JsonExtensions
- Inherited Members
Methods
HasProperty(JsonElement, string)
Checks if the JsonElement contains a property with a specified name.
internal static bool HasProperty(this JsonElement element, string name)
Parameters
element
JsonElementname
string
Returns
ToNode(JsonElement, JsonNodeOptions?)
Converts a JsonElement to the appropriate JsonNode subtype.
internal static JsonNode? ToNode(this JsonElement element, JsonNodeOptions? options = null)
Parameters
element
JsonElementElement to convert
options
JsonNodeOptions?Optional options to pass to JsonNode
Returns
- JsonNode
Node containing the same information
ToNodeOptions(JsonSerializerOptions)
Converts a JsonSerializerOptions into a JsonNodeOptions with the equivalent settings.
internal static JsonNodeOptions ToNodeOptions(this JsonSerializerOptions options)
Parameters
options
JsonSerializerOptions
Returns
TryGetASType(JsonElement, out string?)
Attempts to read the provided JsonElement as an ActivityStreams object and return its type. Returns false if the element does not contain an object or the object does not contain a valid type.
internal static bool TryGetASType(this JsonElement element, out string? type)
Parameters
element
JsonElementobject to read
type
stringSet to the AS type on success, or null on failure
Returns
TryGetString(JsonElement, out string?)
Attempts to read the element as a string. Returns true on success.
internal static bool TryGetString(this JsonElement element, out string? str)
Parameters
element
JsonElementElement to convert
str
stringString that was read
Returns
TryGetString(Utf8JsonReader, out string?)
Attempts to read a string from the provided Utf8JsonReader. Returns false and null if the reader is not positioned at a string or reading fails. Does NOT advance the reader!
internal static bool TryGetString(this Utf8JsonReader reader, out string? type)
Parameters
reader
Utf8JsonReaderReader, not copied because we don't move it
type
stringString that was read