Skip to content

Error -> Type requires a JSON object to deserialize correctly #76

@stunney

Description

@stunney

Describe the bug

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.

To Reproduce
ThirdPartyLibraries update -appName MyApp -repository ./3rdParty -github.com:personalAccessToken $GITHUB_PAT $source

Expected behavior
An updated readme file

Environment

  • OS: macOS (latest)
  • .net framework version net6/7
  • npm for web side logic as well

Additional context
Had no problems in 3.0.0 but quite a few libs have been added.

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ThirdPartyLibraries.Repository.Template.LibraryIndexJson' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ThirdPartyLibraries.Repository.Template.LibraryIndexJson' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at ThirdPartyLibraries.Shared.JsonSerializerExtensions.JsonDeserialize[T](Stream content) in /_/Sources/ThirdPartyLibraries.Shared/JsonSerializerExtensions.cs:line 15
   at ThirdPartyLibraries.Repository.StorageExtensions.ReadLibraryIndexJsonAsync[TModel](IStorage storage, LibraryId id, CancellationToken token) in /_/Sources/ThirdPartyLibraries.Repository/StorageExtensions.cs:line 55
   at ThirdPartyLibraries.Suite.Remove.Internal.PackageRemover.RemoveFromApplicationAsync(LibraryId id, String appName, CancellationToken token) in /_/Sources/ThirdPartyLibraries.Suite/Remove/Internal/PackageRemover.cs:line 38
   at ThirdPartyLibraries.Suite.Update.UpdateCommand.RemoveFromApplicationAsync(ILogger logger, IPackageRemover remover, HashSet`1 references, CancellationToken token) in /_/Sources/ThirdPartyLibraries.Suite/Update/UpdateCommand.cs:line 133
   at ThirdPartyLibraries.Suite.Update.UpdateCommand.ExecuteAsync(IServiceProvider serviceProvider, CancellationToken token) in /_/Sources/ThirdPartyLibraries.Suite/Update/UpdateCommand.cs:line 43
   at ThirdPartyLibraries.CommandChain.ExecuteAsync(IServiceProvider serviceProvider, CancellationToken token) in /home/runner/work/ThirdPartyLibraries/ThirdPartyLibraries/Sources/ThirdPartyLibraries/CommandChain.cs:line 24
   at ThirdPartyLibraries.Program.RunConsoleAsync(CommandLine commandLine, ConsoleLogger logger, CancellationToken token) in /home/runner/work/ThirdPartyLibraries/ThirdPartyLibraries/Sources/ThirdPartyLibraries/Program.cs:line 88

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions