I am fetching json data from txt file in linq and performing some actions on that to making the process fast. but when I am trying to call that query then it's showing me an error for deserialization of json object. So how to deserialize it?
I am getting error like
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List1[MMF.LiveAMData]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
I search to solve this issue but almost all answers performing desrialization without linq. I need to use linq due to time latency.
Below is my method which I am calling
public static void something()
{
File.ReadLines(filePath)
.AsParallel()
.Select(x => x.TrimStart('[').TrimEnd(']'))
.Select(JsonConvert.DeserializeObject<List<LiveAMData>>)
.ForAll(WriteRecord);
}
and below is my class object which I am using
public class LiveAMData
{
public string ev { get; set; }
public string sym { get; set; }
}