nodejs append inside json file in array format

后端 未结 1 1749
粉色の甜心
粉色の甜心 2021-01-13 10:02

I want the nodejs to append all the data in the JSON format in following format

    [{
      \"name\": \"admin\",
      \"message\": \"dfd\",
      \"datetim         


        
相关标签:
1条回答
  • 2021-01-13 10:45

    JSON is not 'appendable' format. You have two options here:

    1. Read file, parse it, append data to array, serialize, replace file content.
    2. Switch to different file format. Actually CSV is good enough to store table-like data and is 'appendable'.
    0 讨论(0)
提交回复
热议问题