Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.3k stars 1.9k forks source link

鸿蒙next版本MMKV 取出的数据比保存的数据丢了一个字符 #1308

Closed xinle closed 4 months ago

xinle commented 4 months ago

import { MMKV } from '@tencent/mmkv';

@Entry @Component struct MMKVTestPage { build() { Row() { Column() { Button("save") .onClick(() => { let str: string = "{\"id\":5,\"name\":\"智能降噪\",\"desc\":\"保证人声和背景音无损伤的情况下,降低声音中的噪声\",\"isNeedVip\":false," + "\"downloadUrl\":\"GEpyiHCvL-PnJgxIcPL86hL_k" + "-GrUrFqfcZYWPMhDJmbDESu95nSbtIfEIbWua_EQgCf1S2oFNVBnCoukhs_mnkBFd6gT3H2f2XobvvjePhvLLiO-5Pqg6Rm_uPveVkW\",\"updateTime\":1699261134000,\"isNewProductFree\":false,\"isAuthorized\":true,\"effectVersion\":5,\"md5\":\"ee463c033e588c9da104755b1da020ca\",\"tags\":\"\",\"canLowDevice\":false,\"isValidMasterClassVip\":false,\"localPath\":\"/data/storage/el2/base/haps/MainApp/files/sound_effect/se_temp/un_zip_se_5__5\"}"; console.log("MMKVTest saveStr " + str) MMKV.defaultMMKV().encodeString('string', str); })

    Button("get")
      .onClick(() => {
        let result = MMKV.defaultMMKV().decodeString('string')
        console.info('MMKVTest getStr = ', result);
      })
  }
  .width('100%')
}
.height('100%')

} }

下面打印出来的结果会少一个字符串 ”}“

xinle commented 4 months ago

20240524102521

lingol commented 4 months ago

Duplicate with #1294