I have json string like below
"{\"Key\":3296,\"Value1\":\"Test1\",\"Value2\":\"City\",\"Value3\":\"TX\",\"Value4\":null,\"Value5\":null,\"Value6\":null}{\"Key\":3297,\"Value1\":\"Test2\",\"Value2\":\"PUD\",\"Value3\":\"TX\",\"Value4\":null,\"Value5\":null,\"Value6\":null}"
and corresponding C# class
public class MyObject
{
public int Key { get; set; }
public string Value1 { get; set; }
public string Value2 { get; set; }
public string Value3 { get; set; }
public string Value4 { get; set; }
public string Value5 { get; set; }
public string Value6 { get; set; }
}
when i try to deserialize this string using Newtonsoft i get error
{"Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.IEnumerable`1[MyObject]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'Key', line 1, position 7."}
I know that the string is not well formatted for json array. This is how i m getting the string and i dont have control over it.
What would be a best option here to convet that string into IEnumerable
of MyObject. The string can have one object also.