OrchardCMS/OrchardCore · error · JsonException

Cannot parse array.

Error message

Cannot parse array.

What it means

The reader entered a JSON array but hit end-of-input before JsonTokenType.EndArray was seen (the while (reader.Read()) loop terminated without returning the list). Like the number case, this indicates truncated or malformed JSON rather than merely unusual content.

Solutions

  1. Check the JSON payload for truncation and unbalanced brackets
  2. Ensure any code that pre-processes or streams the JSON preserves array structure
  3. Re-serialize from the original source rather than hand-editing JSON strings
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/OrchardCore/OrchardCore.Abstractions/Json/Serialization/DynamicJsonConverter.cs:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/ba8ab04506672d25. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Abstractions/Json/Serialization/DynamicJsonConverter.cs:64

                }

                throw new JsonException("Cannot parse number");

            case JsonTokenType.StartArray:
                var list = new List<object?>();
                while (reader.Read())
                {
                    switch (reader.TokenType)
                    {
                        default:
                            list.Add(Read(ref reader, typeof(object), options));
                            break;
                        case JsonTokenType.EndArray:
                            return list;
                    }
                }

                throw new JsonException("Cannot parse array.");

            case JsonTokenType.StartObject:
                var dictionary = new Dictionary<string, object?>();
                while (reader.Read())
                {
                    switch (reader.TokenType)
                    {
                        case JsonTokenType.EndObject:
                            return dictionary;

                        case JsonTokenType.PropertyName:
                            var key = reader.GetString();
                            reader.Read();
                            if (key is not null)
                            {
                                dictionary[key] = Read(ref reader, typeof(object), options);
                            }

View on GitHub (pinned to 4306c0717f)