CrystalJsonParser

Namespace: SnowBank.Data.Json · class

Methods

CouldBeIso8601DateTime

static bool CouldBeIso8601DateTime(ReadOnlySpan<char> value, out DateTimeKind kind)

Tests if the string COULD be a date in the ISO 8601 format

  • value — String literal to parse
  • kind — Receives Utc if ends with 'Z', Local if could end with a time offset, or Unspecified if no offset indication was found

This is a fast heuristic that may have false positives

CouldBeJsonMicrosoftDateTime

static bool CouldBeJsonMicrosoftDateTime(ReadOnlySpan<char> value)

DeserializeCustomClassOrStruct

static object DeserializeCustomClassOrStruct(JsonObject data, Type type, ICrystalJsonTypeResolver resolver)

Deserializes a custom class or struct

ParseJsonNumber

static JsonNumber ParseJsonNumber(string literal)

static JsonNumber ParseJsonNumber(ReadOnlySpan<char> literal, string original = null)

TryParseDateTimeOffsetComponents

static bool TryParseDateTimeOffsetComponents(ReadOnlySpan<char> value, out DateOnly date, out TimeOnly time, out long nanos, out TimeSpan offset, out DateTimeKind kind)

TryParseIso8601DateTime

static bool TryParseIso8601DateTime(ReadOnlySpan<char> value, out DateTime result)

TryParseIso8601DateTimeOffset

static bool TryParseIso8601DateTimeOffset(ReadOnlySpan<char> value, out DateTimeOffset result)

TryParseIso8601Instant

static bool TryParseIso8601Instant(ReadOnlySpan<char> value, out Instant result)

Parses an ISO 8601 date with a time and a Z or +HH:MM suffix into an instant, keeping every nanosecond

A literal without a suffix, or with a negative year, is not handled here: the caller decides what an unspecified kind means.

TryParseMicrosoftDateTime

static bool TryParseMicrosoftDateTime(ReadOnlySpan<char> value, out DateTime result, out TimeSpan? tz)