How to deserialize json to multiple types dynamically in c# [duplicate]

This question already has an answer here:

I have a json string like below :

{
“error” : “xxxx” ,
“data” : int type or {…other complex json object}
}

I don’t know when return int or other json string from data field , and how to deserialize this ?

when type of data is object or dynamic , the real deserialized type of data is int or Dictionary using JavaScriptSerializer.Deserialize(string json).

the real deserialized type of data is Int64 or JContainer when using Json.Net.

is there a elegance way to solve this ? I don’t think reflection is a good way.

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.

remove object from the list if certain statement is true [duplicate]

This question already has an answer here:

using linq I want to check certain condition, if that condition is met I want to remove that object from the list

pseudo code

if any object inside cars list has Manufacturer.CarFormat != null
delete that object

if (muObj.Cars.Any(x => x.Manufacturer.CarFormat != null))
{
    ?
}

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.

Remove an item from a LINQ collection

I think I am putting my question correctly 🙂

I am querying the database using LINQ to retrieve some data. Please find the code below.

var leadtasktype = _context.LeadTypeTaskTypes.Where(l => l.LeadTypeId == item.Value);

foreach(LeadTypeTaskType l in leadtasktype){
    if (l.TaskTypeId == 21)
    {
        //I need to remove an item which has the tasktype id 21
    }
}

As I mentioned in the comments, I need to remove items from the leadtasktype based on my if condition. How do I do this?

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.