com.google.gson错误地序列化为byetArray格式

问题描述

我遇到一个独特的问题。尝试使用com.google.gson将protobuf对象序列化为JSON,但它会将JSON中的某些字段序列化为字节数组格式,而不是常规字符串。 例: 我正在寻找要转换的protobuf对象,如下所示:

{
    "price_": "0","timeOfPurchase": 1597343941000,"serverDetails": "AAA221","device": "ASDDE56838","isOffer": false,"accountNumber_": "11236738","accessories": "printer","productName": "HP Laptop"
}

但是它被转换为:

  {
    "price_": {
      "bytes": [
        43,62,32,22
      ],"hash": 0
    },"timeOfPurchase": 1597345420027,"serverDetails": {
      "bytes": [
        81,70,22,18
      ],"device": {
      "bytes": [
        13,67,53,71,50,41,49,73
      ],"accountNumber_": {
      "bytes": [
        21,83,72,49
      ],"productName": "HP Laptop"
  }

我使用Google GSON库专家的1.7.1版本。 此问题是间歇性发生的,并非总是如此。关于此的任何线索都将真正有帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)