Insert a single object into json file without rewriting entire file

后端 未结 2 738
借酒劲吻你
借酒劲吻你 2021-01-20 15:20

I\'m working on a method that uses JSON.NET to add a horse object to a JSON-formatted database of horses. One option is to deserialize the entire file into a list of horses,

2条回答
  •  旧时难觅i
    2021-01-20 15:35

    No, you couldn't, because serializer should read entire file to complete building JSON object structure. At the same time, this can be done with manual text file editing, but this solution will be doubtful. If you want fast read/write access to data, maybe you should consider another data-structure forms, for example, keepeing horses in DB.

提交回复
热议问题