title: Parse JSON in Google Refine
body: <p>I'm trying to pull out specific elements from results from the Data Science Toolkit coordinates2politics API, using Google Refine.</p>
  
  <p>Here is sample cell #1:</p>
  
  <pre><code>[{"politics":[
   {"type":"admin2","friendly_type":"country","code":"usa","name":"United States"},
   {"type":"admin6","friendly_type":"county","code":"55_025","name":"Dane"},
   {"type":"constituency","friendly_type":"constituency","code":"55_02","name":"Second district, WI"},
   {"type":"admin5","friendly_type":"city","code":"55_48000","name":"Madison"},
   {"type":"admin5","friendly_type":"city","code":"55_53675","name":"Monona"},
   {"type":"admin4","friendly_type":"state","code":"us55","name":"Wisconsin"},
   {"type":"neighborhood","friendly_type":"neighborhood","code":"Eastmorland|Madison|WI","name":"Eastmorland"}
   ],"location":{"longitude":"-89.3259404","latitude":"43.0859191"}}]
  </code></pre>
  
  <p>I added a column based on this column using this GREL syntax to pull out the county, Dane:</p>
  
  <pre><code>value.parseJson()[0]["politics"][1]["name"]
  </code></pre>
  
  <p>But when I got to Sample Cell #2, the syntax no longer works because the JSON result is a little different: </p>
  
  <pre><code>[{"politics":[
   {"type":"admin2","friendly_type":"country","code":"usa","name":"United States"},
   {"type":"constituency","friendly_type":"constituency","code":"55_05","name":"Fifth district, WI"},
   {"type":"admin4","friendly_type":"state","code":"us55","name":"Wisconsin"},
   {"type":"admin6","friendly_type":"county","code":"55_079","name":"Milwaukee"},
   {"type":"admin5","friendly_type":"city","code":"55_84675","name":"Wauwatosa"},
   {"type":"constituency","friendly_type":"constituency","code":"55_04","name":"Fourth district, WI"}
   ],"location":{"longitude":"-88.0075875","latitude":"43.0494572"}}]
  </code></pre>
  
  <p>Is there some way to sort the JSON or phrase my syntax so that I can find the county in either case?</p>
  
  <h3>Update</h3>
  
  <p>Here's the magic GREL that allowed me to find elements in the JSON string by name, not just position:</p>
  
  <pre><code>filter(value.parseJson()[0]["politics"], item, item["type"]=="admin6")[0]["name"]
  </code></pre>