Getting a JObject by a property value I am building a contact management system. Each contact can relate to the business in one of three ways: client, service provider, and third party. 

I have a JSON file containing the relation types and their importance to the business (so I could priorities messages, for example):

{
    "Relations": [
        {
            "Name": "Client",
            "Importance": 1
        },
        {
            "Name": "Service Provider",
            "Importance": 2
        },
        {
            "Name": "ThirdParty",
            "Importance": 3
        }
    ]
}


I have a method that gets the name of the relation and retrieves a JObject containing the JSON representing this relation, using Json.NET:

private JObject GetRelationJSON(string relationName)
{
    string jString = File.ReadAllText("relations.json");
    JObject relationsJSON = JsonConvert.DeserializeObject&lt;JObject&gt;(jString);

    // I am specifically not sure about this line
    return (JObject)(relationsJSON["Relations"].Where(r =&gt; ((string)r["Name"]).Equals(relationName)).ToList()[0]);
}


Note that I am not allowed to deserialize the JSON into POCO classes.

How can I improve this code? Thanks!
Not being able to use POCO is tough enough so don't make your life even harder with the line you're asking about. It's much easier to query it with JsonPath like that:

return (JObject)relationsJSON.SelectToken($"$.Relations[?(@.Name=='{relationName}')]");


and since you are not using POCO then you don't have to deserialize it. It's ok when you just let json.net parse it with JToken and then do the JsonPath thing:

JToken.Parse(json).SelectToken(...);