skip to Main Content

Asp.net – Deserialize an object that can have string or int from JSON format

How do I deserialize an object from JSON format with valid data using JsonConvert.DeserializeObject(useCaseData)? I tried it with JsonConvert.DeserializeObject<Dictionary<string, string>>(useCaseData) But I get this error : Newtonsoft.Json.JsonSerializationException: 'Error converting value 1 to type 'System.Collections.Generic.Dictionary`2[System.String,System.String]'. Path '', line 1, position 1.…

VIEW QUESTION

Why does json.NET give “Additional text encountered after finished reading JSON content”?

I'm trying to deserialize a JSON object. The value of the string 'plaintext' is: {"expiryDay":1,"expiryMonth":6,"expiryYear":2023,"machineGuid":"a3586fb9-b05e-46f1-a4a0-683a97109e34","name":"Alexander Farley"} This line throws an exception: var json = JObject.Parse(plaintext); The exception is: Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: . Path '',…

VIEW QUESTION
Back To Top
Search