Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to deserialize the JSON string to object
    primarykey
    data
    text
    <p>Guyz</p> <p>I am trying to parse a JSON string into object. I have the below entity in which I am parsing the JSON string</p> <pre><code> public class Room : BaseEntity { public string Name { get; set; } public string EmailAddress { get; set; } public string RoomListEmailAddress { get; set; } public string MinimumXCoordinateInMap { get; set; } public string MinimumYCoordinateInMap { get; set; } public string MaximumXCoordinateInMap { get; set; } public string MaximumYCoordinateInMap { get; set; } public string RoomCapacity { get; set; } public List&lt;RoomImage&gt; RoomImage { get; set; } public string FloorName { get; set; } public string CreatedDate { get; set; } public string CreatedId { get; set; } public string LastUpdatedDate { get; set; } public string LastUpdatedId { get; set; } public InternalOnly InternalOnly { get; set; } //public List&lt;Equipment&gt; Equipment { get; set; } public override string ToString() { return this.Name; } } public class RoomImage : BaseEntity { public string ImagePath { get; set; } public string ImageType { get; set; } public string CreatedDate { get; set; } public string CreatedId { get; set; } public string LastUpdatedDate { get; set; } public string LastUpdatedId { get; set; } public InternalOnly InternalOnly { get; set; } } public class InternalOnly : BaseEntity { public string RoomId { get; set; } public string FloorId { get; set; } } public class BaseEntity { } </code></pre> <p>I am using below method to parse the string into object</p> <pre><code> public static T ParseObjectToJSON&lt;T&gt;(string responseText) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T)); using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(responseText))) { var rootObject = serializer.ReadObject(stream); //return Convert.ChangeType(rootObject,typeof(T),System.Globalization.CultureInfo.CurrentCulture.TextInfo); return (T)rootObject; } } </code></pre> <p>Below is the JSON string which I am trying to parse</p> <p><a href="https://docs.google.com/document/d/1k81M_UxIrXpHUPQNDUCHDfNw1wY7LM4mAaXjwpYMshk/edit?usp=sharing" rel="nofollow">https://docs.google.com/document/d/1k81M_UxIrXpHUPQNDUCHDfNw1wY7LM4mAaXjwpYMshk/edit?usp=sharing</a></p> <p>The below json string is working</p> <p><a href="https://docs.google.com/document/d/1uQNwMmSyEZSolyxUVJl6gXzZPr6aRAf_WAogmUvVqt4/edit?usp=sharing" rel="nofollow">https://docs.google.com/document/d/1uQNwMmSyEZSolyxUVJl6gXzZPr6aRAf_WAogmUvVqt4/edit?usp=sharing</a></p> <p>While parsing I get below error</p> <p>The data contract type 'GAP.Entities.Room' cannot be deserialized because the member 'RoomImage' is not public. Making the member public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications.</p> <p>Note- RoomImage is marked public in the entity class. I get this error only when JSON string contains RoomImage array string otherwise no erro.</p> <p>Any help is highly appreciated.</p> <p>Thanks Vinod</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload