logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SteamJsonFieldReader

    Small, tolerant JSON field lookups shared by every Steam partner-site response reader (SteamAchievementResponseReader, SteamSaveResponseReader): none of these undocumented internal endpoints commit to one field-name spelling, so every reader has to probe a short list of candidates rather than a single key.

    Inheritance
    object
    SteamJsonFieldReader
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Steam.Infrastructure
    Assembly: Serenity.Steam.Infrastructure.dll
    Syntax
    public static class SteamJsonFieldReader

    Fields

    BitIdFieldNames

    The field a live response carries an achievement's bit id under.

    Declaration
    public static readonly string[] BitIdFieldNames
    Field Value
    Type Description
    string[]

    StatIdFieldNames

    The field a live response carries an achievement's stat id under.

    Declaration
    public static readonly string[] StatIdFieldNames
    Field Value
    Type Description
    string[]

    Methods

    Render(JsonValue)

    Renders any JSON value as short, readable text — a string as itself, an object as {key: value, …} — for a failure message that must show what the server sent.

    Declaration
    public static string Render(JsonValue value)
    Parameters
    Type Name Description
    JsonValue value
    Returns
    Type Description
    string

    TryGetFlag(JsonValue, IReadOnlyList<string>, out bool)

    Reads the first present success flag among candidateNames: a JSON boolean, a number (1 is true, any other number is false — a legacy status code is not a yes), or one of the strings "0"/"1"/"true"/"false". A present value of any other shape is skipped, so it can neither confirm nor refuse the response.

    Declaration
    public static bool TryGetFlag(JsonValue jsonObject, IReadOnlyList<string> candidateNames, out bool value)
    Parameters
    Type Name Description
    JsonValue jsonObject
    IReadOnlyList<string> candidateNames
    bool value
    Returns
    Type Description
    bool

    TryGetFlexibleBool(JsonValue, IReadOnlyList<string>, out bool, out string)

    Reads the first present field among candidateNames as a boolean, accepting a JSON boolean, the numbers 0/1, and the strings "0"/"1"/"true"/"false" (any casing), and a blank string as false — the encodings the partner site answers a flag with: a live pull answers "0", and a just-created achievement answers "", which its own editor script reads as not set.

    Declaration
    public static bool TryGetFlexibleBool(JsonValue jsonObject, IReadOnlyList<string> candidateNames, out bool value, out string unrecognisedText)
    Parameters
    Type Name Description
    JsonValue jsonObject

    The object to read the field from.

    IReadOnlyList<string> candidateNames

    The field-name spellings to probe, in order.

    bool value

    The decoded flag when one was recognised; otherwise false.

    string unrecognisedText

    Empty when the field is absent or was recognised; otherwise a rendering of the present-but-unrecognised value, so a caller can refuse it instead of guessing a default.

    Returns
    Type Description
    bool

    Whether a recognised value was found.

    TryGetFlexibleString(JsonValue, IReadOnlyList<string>, out string)

    Reads the first present field among candidateNames as a string, accepting either a JSON string or a JSON number (Steam has been observed to answer a numeric id both ways).

    Declaration
    public static bool TryGetFlexibleString(JsonValue jsonObject, IReadOnlyList<string> candidateNames, out string value)
    Parameters
    Type Name Description
    JsonValue jsonObject
    IReadOnlyList<string> candidateNames
    string value
    Returns
    Type Description
    bool

    TryGetString(JsonValue, IReadOnlyList<string>, out string)

    Reads the first present, non-blank string field among candidateNames.

    Declaration
    public static bool TryGetString(JsonValue jsonObject, IReadOnlyList<string> candidateNames, out string value)
    Parameters
    Type Name Description
    JsonValue jsonObject
    IReadOnlyList<string> candidateNames
    string value
    Returns
    Type Description
    bool

    TryGetWholeNumber(JsonValue, IReadOnlyList<string>, out long)

    Reads the first present field among candidateNames as a whole number, accepting a JSON number or a quoted digit string; a fractional or non-numeric value is not a whole number.

    Declaration
    public static bool TryGetWholeNumber(JsonValue jsonObject, IReadOnlyList<string> candidateNames, out long value)
    Parameters
    Type Name Description
    JsonValue jsonObject
    IReadOnlyList<string> candidateNames
    long value
    Returns
    Type Description
    bool
    In this article
    © 2026 Serenity. All Rights Reserved