expand jsons with postgresql

52 Views Asked by At

I have a query using postgresql that is made to expand this json:

    {
      "log": {
        "version": "1.2",
        "creator": {
          "name": "WebInspector",
          "version": "537.36"
        },
        "pages": [
        
    ], 
        "entries": [, 
         "request": {
              "method": "POST",
              "url": "https://www.google.com/gen_204?atyp=csi&ei=vJUtZfGFDYTe1sQPvPKUkAo&s=jsa&jsi=s,st.7949,t.0,at.6,et.click,n.msmzHf,cn.1,ie.1,vi.1&zx=1697486276379&opi=89978449",
              "httpVersion": "h3",
              "headers": []
      }
    ]

this is a .har file that I took from Chrome dev tools.. I didn't put all the json because there are many lines, so this would get in the way..

I'm trying to access the data from this json like this:

    WITH sub_primeiro_parametro AS (
        SELECT 
            *
        FROM jsonipiranga j, JSON_TO_RECORD(CAST(j.contentjson AS JSON)) AS jtr(
            "log" JSON
        ), JSON_TO_RECORD(jtr."log") AS jtre(
            "entries" JSON
        ), JSON_TO_RECORDSET(jtre."entries") AS jtrr (
            "request" TEXT 
        )
    )
    SELECT * FROM sub_primeiro_parametro

but my database returns me an error saying: 'Insufficient memory when retrieving query results.'

I increased the memory of my DBeaver (sql manager that I use) and also of my local postgresql but nothing helped. my doubt is:

The problem may be how I am trying to expand the array? Would this approach I took be the best approach?

If you need more information I will provide it, I am open to study tips thanks

0

There are 0 best solutions below