title: How to convert a Firestore Document to plain json and vice versa
body: <p>I'm trying to fetch firestore document using Rest API and it is returning data in below format</p>
  
  <pre><code>{"fields":{"list1":{"arrayValue":{"values":[{"stringValue":"item1"},{"stringValue":"item2"}]}}}}
  </code></pre>
  
  <p>how can I convert the above Document to plain JavaScript object like below and convert it back to firestore document before making the update call</p>
  
  <pre><code>{"list1":["item1","item2"]}
  </code></pre>
  
  <p>Screenshot of my data from Firestore console
  <a href="https://i.stack.imgur.com/vVpRN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vVpRN.jpg" alt="enter image description here"></a></p>
  
  <p>Edit: More info</p>
  
  <p>json sample1 is returned by Firestore api  and has all datatype info</p>
  
  <p>json sample2 is my actual data without type info.</p>
  
  <p>My issue is firestore RestApi get call is returning the response in json sample1 format. I want to update some info in api response and send back updated values to firestore db. But due to all the type info in the response I'm not able to update the values where necessary. So I'm trying to find if there is a way to convert api response to json sample2.</p>
  
  <p>API URL used : <a href="https://firestore.googleapis.com/v1/projects/projects/" rel="nofollow noreferrer">https://firestore.googleapis.com/v1/projects/projects/</a>{project_id}/databases/{database_id}/documents/{document_path}</p>