abpframework/abp · error · AbpException

JSON value is not an array of objects: {value}

Error message

JSON value is not an array of objects: {value}

What it means

Thrown by SimpleStateCheckerSerializerExtensions.DeserializeArray when the parsed JSON is a one-element (or multi-element) array but an element is not a JsonObject — i.e. the array holds a primitive/array instead of an object. It is an AbpException echoing the offending value. It indicates malformed persisted state-checker data.

Source

Thrown at framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializerExtensions.cs:81

        where TState : IHasSimpleStateCheckers<TState>
    {
        if (value.IsNullOrWhiteSpace())
        {
            return Array.Empty<ISimpleStateChecker<TState>>();
        }
        
        var array = JsonNode.Parse(value) as JsonArray;
        if (array == null || array.Count == 0)
        {
            return Array.Empty<ISimpleStateChecker<TState>>();
        }
        
        if (array.Count == 1)
        {
            var jsonObject = array[0] as JsonObject;
            if (jsonObject == null)
            {
                throw new AbpException("JSON value is not an array of objects: " + value);
            }

            var checker = serializer.Deserialize(jsonObject, state);
            if (checker == null)
            {
                return Array.Empty<ISimpleStateChecker<TState>>();
            }
            
            return new[] { checker };
        }

        var checkers = new List<ISimpleStateChecker<TState>?>();

        for (var i = 0; i < array.Count; i++)
        {
            if (array[i] is not JsonObject jsonObject)
            {
                throw new AbpException("JSON value is not an array of objects: " + value);

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Re-serialize the state checkers via the Serialize extension to get a valid JSON-object array, then persist that.
  2. Clear/reset the corrupted persisted state-checker value so it regenerates.
  3. After an ABP upgrade, run any provided migration for persisted state-checker data or re-save the entities.
  4. Validate the stored JSON shape before calling DeserializeArray (parse and assert each element is a JsonObject).

Example fix

// before
// persisted value: ["MyChecker"]  (malformed)
var checkers = serializer.DeserializeArray(storedJson, state);

// after
// persisted value: [{"Name":"MyChecker","IsGlobal":false}]
var checkers = serializer.DeserializeArray(storedJson, state);
Defensive patterns

Strategy: validation

Validate before calling

static bool IsValidCheckerJson(string value)
{
    if (value.IsNullOrWhiteSpace()) return true;
    var arr = JsonNode.Parse(value) as JsonArray;
    return arr is null || arr.All(e => e is JsonObject);
}

if (!IsValidCheckerJson(storedJson)) { /* reset/regenerate */ }

Type guard

static bool IsJsonObjectArray(JsonNode? node)
    => node is JsonArray arr && arr.All(e => e is JsonObject);

Try / catch

try { var checkers = serializer.DeserializeArray(storedJson, state); }
catch (AbpException ex) when (ex.Message.Contains("not an array of objects"))
{
    logger.LogWarning(ex, "Corrupted state-checker data; resetting");
    storedJson = null; // regenerate
}

Prevention

When it happens

Trigger: Calling DeserializeArray(stateCheckersJson, state) where the JSON is like ["foo"] or [[...]] instead of [{"Name":"...",...}].

Common situations: Corrupted persisted simple-state-checker data (DB column, cache entry), a schema change between ABP versions that altered the serialized shape, or hand-edited/migrated data that is not a JSON object array.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/4681cc6b15435bfc. Report an issue: GitHub.