JsonArrayExtensions
Namespace: SnowBank.Data.Json · class
Extension methods for JsonArray
Methods
AddRange
static JsonArray AddRange(JsonArray self, IEnumerable<JsonObject> values)
Appends all the elements of an IEnumerable to the end of this JsonArray
Any mutable element in will be converted to read-only before being added. Elements that were already read-only will be added be reference.
static JsonArray AddRange(JsonArray self, JsonObject[] values)
Appends all the elements of an array to the end of this JsonArray
Any mutable element in will be converted to read-only before being added. Elements that were already read-only will be added be reference.
AddRangeReadOnly
static JsonArray AddRangeReadOnly(JsonArray self, IEnumerable<JsonObject> values)
Appends all the elements of an IEnumerable to the end of this JsonArray
Any mutable element in will be converted to read-only before being added. Elements that were already read-only will be added be reference.
static JsonArray AddRangeReadOnly(JsonArray self, JsonObject[] values)
Appends all the elements of an array to the end of this JsonArray
Any mutable element in will be converted to read-only before being added. Elements that were already read-only will be added be reference.
MapTo
static IDictionary<TKey, TValue> MapTo<TKey, TValue>(IEnumerable<JsonValue> source, IDictionary<TKey, TValue> target, JsonType? expectedType, Func<JsonValue, JsonValue> keySelector, Func<JsonValue, JsonValue> valueSelector, ICrystalJsonTypeResolver resolver = null, bool overwrite = false)
Maps the elements of a list into a Dictionary
source— Sequence of non-null elements to be mapped.target— Target dictionary that will receive the mapped key/value pairsexpectedType— Expected type for the objects in the sequence (or null if unknown)keySelector— Lambda used to extract a key for each element in the sequencevalueSelector— Lambda used to extract a value for each element in the sequenceresolver— Custom type resolveroverwrite— Iftrue, overwrite existing keys intarget. Iffalse, throws an exception in case of duplicate keys
Returns: The value of target
Pick
static JsonArray Pick(IEnumerable<JsonValue> source, JsonObject defaults)
Returns a list of objects with only the fields listed in defaults.
static JsonArray Pick(IEnumerable<JsonValue> source, IDictionary<string, JsonValue> defaults)
Returns a list of objects with only the fields listed in defaults.
static JsonArray Pick(IEnumerable<JsonValue> source, object defaults)
Returns a list of objects with only the fields listed in defaults.
static JsonArray Pick(IEnumerable<JsonValue> source, ReadOnlySpan<string> keys, bool keepMissing = false)
Returns a list of objects with only the fields listed in keys.
static JsonArray Pick(IEnumerable<JsonValue> source, IEnumerable<string> keys, bool keepMissing = false)
Returns a list of objects with only the fields listed in keys.
ToArray
static TValue[] ToArray<TValue>(JsonArray self, Func<JsonValue, TValue> transform)
Returns an array of TValue containing the transformed elements of a JsonArray
This is the logical equivalent of array.Select(transform).ToArray()
ToJsonArray
static JsonArray ToJsonArray(ReadOnlySpan<JsonValue> source)
Creates a JsonArray from a read-only span.
source— TheReadOnlySpanto create a JsonArray from.
Returns: A JsonArray that contains elements from the input span.
static JsonArray ToJsonArray(Span<JsonValue> source)
Creates a JsonArray from a span.
source— TheReadOnlySpanto create a JsonArray from.
Returns: A JsonArray that contains elements from the input span.
static JsonArray ToJsonArray(JsonValue[] source)
Creates a JsonArray from an array.
source— The array to create a JsonArray from.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray(JsonObject[] source)
Creates a JsonArray from an array.
source— The array to create a JsonArray from.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray(IEnumerable<JsonValue> source)
Creates a JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray(IEnumerable<JsonObject> source)
Creates a JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray<TSource>(IEnumerable<TSource> source, Func<TSource, JsonValue> selector)
Transforms the elements of an IEnumerable into a new JsonArray
Returns: A JsonArray that contains values transformed from the elements of the input sequence.
static JsonArray ToJsonArray<TSource>(IEnumerable<TSource> source, Func<TSource, JsonObject> selector)
Transforms the elements of an IEnumerable into a new JsonArray
Returns: A JsonArray that contains values transformed from the elements of the input sequence.
static JsonArray ToJsonArray<TTKey, TValue>(IDictionary<TTKey, TValue> source, Func<TTKey, TValue, JsonValue> selector)
Transforms the elements of an IEnumerable into a new JsonArray
Returns: A JsonArray that contains values transformed from the elements of the input sequence.
static JsonArray ToJsonArray<TTKey, TValue>(IDictionary<TTKey, TValue> source, Func<TTKey, TValue, JsonObject> selector)
Transforms the elements of an IEnumerable into a new JsonArray
Returns: A JsonArray that contains values transformed from the elements of the input sequence.
static JsonArray ToJsonArray<TElement>(IEnumerable<TElement> source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray<TElement>(ReadOnlySpan<TElement> source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a JsonArray from a read-only span.
source— TheReadOnlySpanto create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A JsonArray that contains elements from the input span.
static JsonArray ToJsonArray<TElement>(TElement[] source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a JsonArray from an array.
source— The array to create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArray<TSource, TValue>(IEnumerable<TSource> source, Func<TSource, TValue> selector, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Transforms the elements of an IEnumerable into a new JsonArray
Returns: A JsonArray that contains values transformed from the elements of the input sequence.
ToJsonArrayReadOnly
static JsonArray ToJsonArrayReadOnly(ReadOnlySpan<JsonValue> source)
Creates a read-only JsonArray from a read-only span.
source— TheReadOnlySpanto create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input span.
static JsonArray ToJsonArrayReadOnly(Span<JsonValue> source)
Creates a read-only JsonArray from a span.
source— TheReadOnlySpanto create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input span.
static JsonArray ToJsonArrayReadOnly(JsonValue[] source)
Creates a read-only JsonArray from an array.
source— The array to create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly(JsonObject[] source)
Creates a read-only JsonArray from an array.
source— The array to create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly(IEnumerable<JsonValue> source)
Creates a read-only JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly(IEnumerable<JsonObject> source)
Creates a read-only JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly<TElement>(IEnumerable<TElement> source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a read-only JsonArray from an IEnumerable.
source— TheIEnumerableto create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly<TElement>(ReadOnlySpan<TElement> source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a read-only JsonArray from a read-only span.
source— TheReadOnlySpanto create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A read-only JsonArray that contains elements from the input span.
static JsonArray ToJsonArrayReadOnly<TElement>(TElement[] source, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Creates a read-only JsonArray from an array.
source— The array to create a JsonArray from.settings— Serialization settings (use default JSON settings if null)resolver— Optional custom resolver used to bind the value into a managed type.
Returns: A read-only JsonArray that contains elements from the input sequence.
static JsonArray ToJsonArrayReadOnly<TSource>(IEnumerable<TSource> source, Func<TSource, JsonValue> selector, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Transforms the elements of an IEnumerable into a new read-only JsonArray
Returns: A read-only JsonArray that contains values transformed from the elements of the input sequence.
static JsonArray ToJsonArrayReadOnly<TSource, TValue>(IEnumerable<TSource> source, Func<TSource, TValue> selector, CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Transforms the elements of an IEnumerable into a new read-only JsonArray
Returns: A read-only JsonArray that contains values transformed from the elements of the input sequence.
ToList
static List<TValue> ToList<TValue>(JsonArray self, Func<JsonValue, TValue> transform)
Returns a List containing the transformed elements of a JsonArray
This is the logical equivalent of array.Select(transform).ToList()