How to save ArrayBuffer?

后端 未结 3 1876
北恋
北恋 2020-12-22 07:56

How to save an ArrayBuffer in json file? I use electron-config for this, but in config.json I found \"{}\". I try convert (code) ArrayBuffer to string, but then I can\'t con

3条回答
  •  無奈伤痛
    2020-12-22 08:23

    There are no ArrayBuffers in the JSON format (only strings, numbers, booleans, null, objects and arrays) so if you want to save an ArrayBuffer in JSON then you'll have to represent it in one of those types (probably a string or an array of numbers).

    Then when you read the JSON you will have to convert it back into an ArrayBuffer, reversing the transformation that you did before.

提交回复
热议问题