Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:04:01+00:00 2026-05-24T17:04:01+00:00

Exception Cannot deserialize JSON object into type ‘System.String’. Controller var products = session.Query<Package>().Select(m =>

  • 0

Exception

Cannot deserialize JSON object into type 'System.String'.

Controller

var products = session.Query<Package>().Select(m => new PackageViewModel() {
    Description = m.Description,
    Id = m.Id,
    Title = m.Title,
    Urls = m.Items.Select(g => g.Url).ToArray() //string[] Urls
});

When I changed Urls to an object and did the assignment Urls was set to the full value of m.Items rather than a list of Urls.

By changing the above to the following it works just fine.

var products = session.Query<Package>().ToList();

var viewModel = products.Select(m => new PackageViewModel() {
    Description = m.Description,
    Id = m.Id,
    Title = m.Title,
    Urls = m.Items.Select(g => g.Url).ToArray()
}).ToList();

This really isn’t a problem but I’m wondering if I’m doing something wrong.

Full StackTrace

[JsonSerializationException: Cannot deserialize JSON object into type 'System.String'.]
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:417
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:223
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:208
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, String reference, JsonArrayContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:719
Newtonsoft.Json.Serialization.<>c__DisplayClass1.<CreateAndPopulateList>b__0(IList l, Boolean isTemporaryListReference) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:665
Newtonsoft.Json.Utilities.CollectionUtils.CreateAndPopulateList(Type listType, Action`2 populateList) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Utilities\CollectionUtils.cs:544

Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateList(JsonReader reader, String reference, JsonArrayContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:653
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:446
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:225
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueProperty(JsonReader reader, JsonProperty property, Object target, Boolean gottenCurrentValue, Object currentValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:198
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonReader reader, Object target) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:552
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, String id) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:1028
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader, JsonObjectContract contract, String id) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:858
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:396
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:223

Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:208
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:120
Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonSerializer.cs:421
Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonSerializer.cs:413
Raven.Client.Document.SessionOperations.QueryOperation.DeserializedResult(RavenJObject result) in c:\Builds\raven\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:173
Raven.Client.Document.SessionOperations.QueryOperation.Deserialize(RavenJObject result) in c:\Builds\raven\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:139
System.Linq.WhereSelectListIterator`2.MoveNext() +110
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +327
System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
Raven.Client.Document.SessionOperations.QueryOperation.Complete() in c:\Builds\raven\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:111
Raven.Client.Document.AbstractDocumentQuery`2.GetEnumerator() in c:\Builds\raven\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:551
Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator() in c:\Builds\raven\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:94
Raven.Client.Linq.RavenQueryInspector`1.System.Collections.IEnumerable.GetEnumerator() in c:\Builds\raven\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:99
System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +61
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +1380
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +194
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat) +26
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) +74
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj) +6
Mvc.Areas.Api.Controllers.PackagesController.List() in PackagesController.cs:38
lambda_method(Closure , ControllerBase , Object[] ) +96
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:04:02+00:00Added an answer on May 24, 2026 at 5:04 pm

    The linq parser isn’t smart enough to deal with this projection.
    It can do simple projections, but nested stuff are quite complex, and aren’t supported.
    You can do that using the LuceneQuery API (the field to load is “Items,Url”)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Exception: Cannot convert the value in attribute 'Text' to object of type 'System.String'. Unable
string insertCommand = INSERT INTO Users (UserID) VALUES ('+UsersIdentityToinsert+'); //Exception: Cannot insert the value
I cannot run ['abc'].append( MyModel.objects.all() ) since it generates exception 'NoneType' object is not
I need to deserialize some JavaScript object represented in JSON to an appropriate C#
I am trying to deserialize/map the below JSON to List<Bill > java object using
Can not deserialize following object graph. That Exception occurs when deserialize method called on
I am trying to deserialize the following xml structure into an object... <?xml version=1.0
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
I can fix the below exception with a try-catch loop but I cannot understand
Suppose you want to throw Exception like this: 'Project with the provided ID cannot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.