I'm trying to fetch firestore document using Rest API and it is returning data in below format
{"fields":{"list1":{"arrayValue":{"values":[{"stringValue":"item1"},{"stringValue":"item2"}]}}}}
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
{"list1":["item1","item2"]}
Screenshot of my data from Firestore console

Edit: More info
json sample1 is returned by Firestore api and has all datatype info
json sample2 is my actual data without type info.
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.
API URL used : https://firestore.googleapis.com/v1/projects/projects/{project_id}/databases/{database_id}/documents/{document_path}