title: JSONPath expressions: getting the value of a specific attribute based on it's presence or the value of another attribute
body: <p>I have JSON structure that is a nested parent/child kind of structure:</p>
  
  <pre><code>{
    "type": "site",
    "profile_id": "site profile id",
    "children": [
      {
        "type": "dealer",
        "profile_id": "dealer profile id",
        "children": [
          {
            "type": "location",
            "profile_id": "location profile id",
            "children": [
              {
                "type": "customer",
                "profile_id": "customer profile id",
                "children": [
                  {
                    "type": "farm",
                    "farm_id": "farm id",
                    "children": [
                      {
                        "type": "field",
                        "field_id": "field id"
                       }]}]}]}]}]}
  </code></pre>
  
  <p>Is there some way in JSONPath to do one of the following:</p>
  
  <ol>
  <li><p>give me the profile_id if it's present, or give me the farm_id if
  it's present,    or give me the field_id if it's present.</p></li>
  <li><p>give me the profile_id if type=customer, or give me the farm_id, if type=farm,    or give me the field_id if type=field</p></li>
  <li><p>give me the nth attribute from each class.  The id is actually the third attribute in each class.  This is my least favorite option, because I don't know if the id will always be the third attribute.</p></li>
  </ol>