Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidOperationException: Cannot skip tokens on partial JSON. #110

Open
kevbite opened this issue Jun 15, 2022 · 0 comments
Open

InvalidOperationException: Cannot skip tokens on partial JSON. #110

kevbite opened this issue Jun 15, 2022 · 0 comments

Comments

@kevbite
Copy link

kevbite commented Jun 15, 2022

We've just bumped into this problem with deserializing JSON into an object, looks like it's similar to this Stackoverflow post (https://stackoverflow.com/questions/63038334/how-do-i-handle-partial-json-in-a-jsonconverter-while-using-deserializeasync-on)

I'm not sure how to fix it but seems to be coming from the custom convertor.

Dahomey.Json.MemberJsonException: The JSON value could not be converted to System.Collections.Generic.IReadOnlyList`1[Models.People.PersonResourceRepresentation]. Path: $.people
 ---> System.InvalidOperationException: Cannot skip tokens on partial JSON. Either get the whole payload and create a Utf8JsonReader instance where isFinalBlock is true or call TrySkip.
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.ReadValue(Utf8JsonReader& reader, Object obj, ReadOnlySpan`1 memberName, JsonSerializerOptions options, HashSet`1 readMembers)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.ReadMember(Utf8JsonReader& reader, T& obj, IObjectConverter& converter, JsonSerializerOptions options, Dictionary`2& creatorValues, Dictionary`2& regularValues, HashSet`1 readMembers, String id)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.Read(Utf8JsonReader& reader, T& obj, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.AbstractCollectionConverter`2.Read(Utf8JsonReader& reader, TC& obj, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.AbstractCollectionConverter`2.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.MemberConverter`2.Read(Utf8JsonReader& reader, Object obj, JsonSerializerOptions options)
 --- End of inner exception stack trace ---
 at Dahomey.Json.Serialization.Converters.MemberConverter`2.Read(Utf8JsonReader& reader, Object obj, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.ReadValue(Utf8JsonReader& reader, Object obj, ReadOnlySpan`1 memberName, JsonSerializerOptions options, HashSet`1 readMembers)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.ReadMember(Utf8JsonReader& reader, T& obj, IObjectConverter& converter, JsonSerializerOptions options, Dictionary`2& creatorValues, Dictionary`2& regularValues, HashSet`1 readMembers, String id)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.Read(Utf8JsonReader& reader, T& obj, JsonSerializerOptions options)
 at Dahomey.Json.Serialization.Converters.ObjectConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
 at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
 at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
 at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
 at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options)
 at System.Text.Json.JsonSerializer.ReadAllAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
 at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)

kevbite added a commit to Exizent/Exizent.NET that referenced this issue Jun 15, 2022
… InvalidOperationException: "Cannot skip tokens on partial JSON" exception when trying to use JsonSerializer.DeserializeAsync(stream).

Links: dahomey-technologies/Dahomey.Json#110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant