title: How to extract the result of a query from JSON inside a custom javascript function in OrientDB
body: <p>I created a custom javascript function in the OrientDB Studio. The function takes a rid as an argument and performs a select query from that rid.</p>
  
  <pre><code>var graph = orient.getGraph();
  var res = graph.command( "sql", "select outE('Rel').inV('B').size() as lower_num from " + rid );
  </code></pre>
  
  <p>So, the result of this query  is a number. Depending on the value of this number the function should do different things. I wonder how to extract and use that value from the res variable inside the function. All my attempts have failed so far.. If I return the res variable from the function, the result looks like this: </p>
  
  <pre><code>[
   {
     "@type": "d",
     "@rid": "#-2:1",
     "@version": 0,
     "lower_num": 2
   }
  ]
  </code></pre>
  
  <p>So, I tried the following <code>( res[0]['lower_num'] == 2 ); ( res['lower_num'] == 2 )</code> and nothing worked.. They always returned false. Any ideas?</p>