How to access data passed to jinija template from the webpage using javascript

I am passing a python list that contains two lists within it to a template. The code is as follows:

return render_template("result.html", result=pythonList)

where pythonList follows the structure:

[[a list of positive comments], [a list of negative comments]]

my result.html is as follows:

<div id = "commentsContainer">
</div>

<a onclick="displayPositive()">positive comments</a>
<a onclick="displayNegative()">negative comments</a>

<script>
   function displayPositive(){
      //code to assign the result[0] list to a const javascript variable called positive
      
   }
   function displayPositive(){
      //code to assign the result[1] list to a const javascript variable called negative
   }
</script>
                 

I tried to pass in the pythonList as json using

return render_template("result.html", result=json.dumps(pythonList))

but I am not sure if this is standard practice. I also dont know how to access this result json either. This is what I tried so far.