【问题标题】:Json String parseJson 字符串解析
【发布时间】:2021-04-13 14:26:57
【问题描述】:

我有一个从编码返回的 json 字符串:

...","AppPW":"1026"}]} <-

最后是一些未定义的字符,有时更多有时更少。 怎样才能跳过它们。

非常感谢

【问题讨论】:

  • 您要从编码中恢复它们?编码过程是您可以控制的吗? (只是检查..如果一开始没有添加它们,则不需要删除它们)

标签: json flutter parsing


【解决方案1】:

这是编码,我无法控制 最后某个时间 0x01,0x01,0x01,0x01 或 0x03,0x03,0x03 或 0x03B

//================================================================
//
//================================================================
Uint8List aes_cbc_decrypt(Uint8List key, Uint8List iv, String base64String)
{

  Uint8List cipherText=base64.decode(base64String);

  final cbc = CBCBlockCipher(AESFastEngine())
    ..init(false, ParametersWithIV(KeyParameter(key), iv)); // false=decrypt

  final paddedPlainText = Uint8List(cipherText.length); // allocate space

  var offset = 0;
  while (offset < cipherText.length) {
    offset += cbc.processBlock(cipherText, offset, paddedPlainText, offset);
  }
  assert(offset == cipherText.length);

  return paddedPlainText;

}

【讨论】:

    【解决方案2】:

    我找到了解决方案 ret= text.replaceAll(RegExp(r'[^\x20-\x7E]'), '');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 2021-04-25
      • 2014-07-22
      • 2015-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多