title: JSON: convert epoch timestamp - jq: error (at <stdin>): Cannot index string with string "timestamp"
body: <p>raw file</p>
  
  <pre><code>$ &lt; galera-healthcheck.stdout.log  jq '.' | head -n 40
  {
    "timestamp": "1499779398.544612646",
    "source": "Galera Healthcheck",
    "message": "Galera Healthcheck.Opened DB connection",
    "log_level": 1,
    "data": {
      "dbHost": "0.0.0.0",
      "dbPort": 3306,
      "dbUser": "galera-healthcheck"
    }
  }
  {
    "timestamp": "1499779398.544713974",
    "source": "Galera Healthcheck",
    "message": "Galera Healthcheck.Serving healthcheck endpoint",
    "log_level": 1,
    "data": {
      "url": "http://0.0.0.0:9200/"
    }
  }
  {
    "timestamp": "1499779398.544794559",
    "source": "Galera Healthcheck",
    "message": "Galera Healthcheck.Attempting to GET endpoint...",
    "log_level": 1,
    "data": {
      "url": "http://0.0.0.0:9200/"
    }
  }
  {
    "timestamp": "1499779398.545407295",
    "source": "Galera Healthcheck",
    "message": "Galera Healthcheck.Failed to process request",
    "log_level": 2,
    "data": {
      "error": "Cannot get status from galera"
    }
  }
  {
    "timestamp": "1499779398.545511246",
  </code></pre>
  
  <p>I wish the same raw file, but the timestamps in human readable form. </p>
  
  <p>I tried:</p>
  
  <pre><code>&lt; galera-healthcheck.stdout.log  jq 'map(if .timestamp then .timestamp |= todate else . end)'
  </code></pre>
  
  <p>and got this error for every line in file</p>
  
  <pre><code>(...)
  jq: error (at &lt;stdin&gt;:968): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:969): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:970): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:971): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:972): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:973): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:974): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:975): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:976): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:977): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:978): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:979): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:980): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:981): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:982): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:983): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:984): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:985): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:986): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:987): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:988): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:989): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:990): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:991): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:992): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:993): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:994): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:995): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:996): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:997): Cannot index string with string "timestamp"
  jq: error (at &lt;stdin&gt;:998): Cannot index string with string "timestamp"
  </code></pre>
  
  <p>Update after first answer:</p>
  
  <blockquote>
    <p>Drop the call to 'map'.</p>
    
    <p>'todate' expects its input to be numeric, so
    you will need to add a call to 'tonumber'.</p>
  </blockquote>
  
  <p>timestamps still in epoch format, not human readable:</p>
  
  <pre><code>&lt; galera-healthcheck.stdout.log  jq '(if .timestamp then .timestamp |= tonumber else . end)' | head
  {
    "timestamp": 1499779398.5446126,
    "source": "Galera Healthcheck",
    "message": "Galera Healthcheck.Opened DB connection",
    "log_level": 1,
    "data": {
      "dbHost": "0.0.0.0",
      "dbPort": 3306,
      "dbUser": "galera-healthcheck"
    }
  </code></pre>