You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespace ASPCoreJSON.Models { public class AlbumData { public int userId { get; set; } public int id { get; set; } public string title { get; set; } public string? icon { get; set; } public string? li_attr { get; set; } = string.Empty; } }
When parsing JSON
{
"userId": 2,
"id": 11,
"title": "quam nostrum impedit mollitia quod et dolor",
"li_attr": {"class": "red"}
}
like: var json = webClient.DownloadString(@"Albums.json"); var albums = JsonConvert.DeserializeObject<List<AlbumData>>(json);
Error: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '[10].li_attr', line 57, position 16.
The wrong character is "{" in li_attr JSON. How I need to declare it in JSON to be able to Deserialize it correctly with Newtonsoft.Json???
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
in ASP.NET MVC I have model defined like
namespace ASPCoreJSON.Models { public class AlbumData { public int userId { get; set; } public int id { get; set; } public string title { get; set; } public string? icon { get; set; } public string? li_attr { get; set; } = string.Empty; } }
When parsing JSON
{
"userId": 2,
"id": 11,
"title": "quam nostrum impedit mollitia quod et dolor",
"li_attr": {"class": "red"}
}
like:
var json = webClient.DownloadString(@"Albums.json"); var albums = JsonConvert.DeserializeObject<List<AlbumData>>(json);
Error:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '[10].li_attr', line 57, position 16.
The wrong character is "{" in li_attr JSON. How I need to declare it in JSON to be able to Deserialize it correctly with Newtonsoft.Json???
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions