Q:

JToken get a specific value

I have following JToken output.  How can I retrieve the 'value' here from TenantID which should be 1 in this case? 
{[
 {
  "value": 1,
  "metadata": {
   "userType": 0,
   "flags": 8,
   "type": {
    "type": "INT4",
    "name": "Int",
    "id": 56
   },
   "colName": "TenantID"
  }
 }
]}

This is my current code :
        JToken value;
        if (usr. Profile. TryGetValue("tenantid", out value))
        {
            JObject inner = value["value"].Value<JObject>(); //not working with null error
            User. TenantID = (string)value;
        }
        User.obj = usr. Profile;

EDIT - please find below the complete JToken output :
    {[
    {
    "value": 1,
    "metadata": {
      "userType": 0,
      "flags": 8,
      "type": {
        "type": "INT4",
        "name": "Int",
        "id": 56
      },
      "colName": "TenantID"
    }
    }
    ]}
    Count: 1
    First (Newtonsoft. Json. Linq. JContainer): {{
  "value": 1,
  "metadata": {
    "userType": 0,
    "flags": 8,
    "type": {
      "type": "INT4",
      "name": "Int",
      "id": 56
    },
    "colName": "TenantID"
  }
}}
    First (Newtonsoft. Json. Linq. JToken): {{
  "value": 1,
  "metadata": {
    "userType": 0,
    "flags": 8,
    "type": {
      "type": "INT4",
      "name": "Int",
      "id": 56
    },
    "colName": "TenantID"
  }
}}
    HasValues: true
    IsReadOnly: false
    Last (Newtonsoft. Json. Linq. JContainer): {{
`"value": 1,
  "metadata": {
    "userType": 0,
    "flags": 8,
    "type": {
      "type": "INT4",
      "name": "Int",
      "id": 56
    },
    "colName": "TenantID"
  }
}}
    Last (Newtonsoft. Json. Linq. JToken): {{
  "value": 1,
  "metadata": {
    "userType": 0,
    "flags": 8,
    "type": {
      "type": "INT4",
      "name": "Int",
      "id": 56
    },
    "colName": "TenantID"
  }
}}
    Next: (null)
    Parent: {"tenantid": [
  {
    "value": 1,
    "metadata": {
      "userType": 0,
      "flags": 8,
      "type": {
        "type": "INT4",
        "name": "Int",
        "id": 56
      },
      "colName": "TenantID"
    }
  }
]}
    Path: "tenantid"
    Previous: (null)
    Static members: 
    Non-public members: 
    IEnumerator: 
    Root: {{
  "name": "Rx Sidhu",
  "given_name": "Rx",
  "family_name": "Sidhu",
  "locale": "en_US",
  "emails": [
    "ranxdeep@xxx.com",
    "ranxdeep@xxx.com",
    "ranxdeep@hx.com"
  ],
  "nickname": "ranxdeep@xxx.com",
  "email": "ranxdeep@xxx.com",
  "picture": "https://apis.live.net/v5.0/f1xxxxxx/picture",
  "roles": [
    "Account Admin",
    "Admin"
  ],
  "tenantid": [
    {
      "value": 1,
      "metadata": {
        "userType": 0,
        "flags": 8,
        "type": {
          "type": "INT4",
          "name": "Int",
          "id": 56
        },
        "colName": "TenantID"
      }
    }
  ],
  "email_verified": true,
  "clientID": "wxxxvC8",
  "updated_at": "2015-07-15T16:26:30.526Z",
  "user_id": "windowslive|f1axxxac",
  "identities": [
    {
      "access_token": "EwBwAq1",
      "provider": "windowslive",
      "user_id": "f1aexxxxxac",
      "connection": "windowslive",
      "isSocial": true
    }
  ],
  "created_at": "2015-07-01T06:08:21.358Z"
}}
    Type: 2

I need to check if the tenantID actually  exists and then get value, else return null or 0. 

A:

You should be able to do:
JObject jObject = JObject. Parse(...);
JToken value = jObject. SelectToken("value");

You parse your object, then the inner contents should be exposed in which you can leverage the SelectToken method to find that specific value.   
To build it out a bit, you could potentially do:
public static JToken FindToken<T>(string key, T value)
{
     string serialized = NewtonsoftJsonSerializer. Instance. Serialize(value);
     var jObject = JObject. Parse(serialized);
     var jToken = jObject. SelectToken(key);

     if(jToken ! = null)
          return jToken;

     return null;
}

A:

I got what I was looking for : 
JToken value;
        if (usr. Profile. TryGetValue("tenantid", out value))
        {
            User. TenantID = (int)value [0] ["value"];
        }

