title: PostgreSQL return JSON objects as key-value pairs
body: <p>A PostgreSQL instance stores data in JSONB format:</p>
  
  <pre><code>CREATE TABLE myschema.mytable (
      id   BIGSERIAL PRIMARY KEY,
      data JSONB     NOT NULL
  )
  </code></pre>
  
  <p>The data array might contain objects like:</p>
  
  <pre><code>{
    "observations": {
      "temperature": {
        "type": "float",
        "unit": "C",
        "value": "23.1"
      },
      "pressure": {
        "type": "float",
        "unit": "mbar",
        "value": "1011.3"
      }
    }
  }
  </code></pre>
  
  <p>A selected row should be returned as key-value pairs in a format like:</p>
  
  <pre><code>temperature,type,float,value,23.1,unit,C,pressure,type,float,value,1011.3,unit,mbar
  </code></pre>
  
  <p>The following query returns at least each object, while still JSON:</p>
  
  <pre><code>SELECT id, value FROM mytable JOIN jsonb_each_text(mytable.data-&gt;'observations') ON true;
  1 | {"type": "float", "unit": "mbar", "value": 1140.5}
  1 | {"type": "float", "unit": "C", "value": -0.9}
  5 | {"type": "float", "unit": "mbar", "value": "1011.3"}
  5 | {"type": "float", "unit": "C", "value": "23.1"}
  </code></pre>
  
  <p>But the results are splitted and not in text format.</p>
  
  <p>How can I return key-value pairs of all objects in <code>data</code>?</p>