OrchardCMS/OrchardCore · error · JsonException

Cannot parse object.

Error message

Cannot parse object.

What it means

The reader entered a JSON object but hit end-of-input before JsonTokenType.EndObject was seen (the while loop over reader.Read() fell through without returning the dictionary). The object literal is truncated or otherwise structurally invalid.

Solutions

  1. Validate the JSON document with a parser to locate the unclosed object
  2. Fix whatever truncates the payload (size limits, partial writes, cut-off HTTP bodies)
  3. Avoid constructing JSON by string concatenation; use a serializer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/OrchardCore/OrchardCore.Abstractions/Json/Serialization/DynamicJsonConverter.cs:86 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/fc32fe7ddb535f69. Report an issue: GitHub.

Appendix: source

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

                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);
                            }

                            break;

                        default:
                            throw new JsonException("Cannot parse object.");
                    }
                }

                throw new JsonException();

            default:
                throw new JsonException(string.Format("Unknown token type {0}", reader.TokenType));
        }
    }

    public override void Write(
        Utf8JsonWriter writer,
        object objectToWrite,
        JsonSerializerOptions options) =>
        JsonSerializer.Serialize(writer, objectToWrite, objectToWrite.GetType(), options);
}

View on GitHub (pinned to 4306c0717f)