donglilian0061 2014-06-26 23:43
浏览 16
已采纳

在appspot.com上解析64位int不同于在localhost上解析?

When you try to parse a 64-bit integer in JavaScript (parseInt("5838406743490560")) it works on the localhost server but not on the Appspot.com server. On the appspot.com server you need to parse it as a string instead of a int64. Does anyone know why that is?

On localhost I can do this:

type Entity struct {
    List []*Message `json:"list"`
}

type Message struct {
    Id int64 `json:"id" datastore:"-"`
}

After uploading it to appspot.com, I need to parse it as a string or I get the error message below.

type Entity struct {
    List []*Message `json:"list"`
}

type Message struct {
    Id int64 `json:"id,string" datastore:"-"`
}

Package that gets sent where id=parseInt("5838406743490560"):

[{"jsonrpc":"2.0","id":"gapiRpc","method":"service.datastore.delete","apiVersion":"v0","params":{"list":[{"id":5838406743490560}]}}]
  • On Appspot.com I can not unmarshal using json:"id" datastore:"-".

  • On localhost it works perfect.

Error on Appspot.com only:

[
 {
  "error": {
   "code": 400,
   "message": "json: cannot unmarshal string into Go value of type int64",
   "data": [
    {
     "domain": "global",
     "reason": "badRequest",
     "message": "json: cannot unmarshal string into Go value of type int64"
    }
   ]
  },
  "id": "gapiRpc"
 }
]

I am using SDK v1.9.6.

  • 写回答

1条回答 默认 最新

  • dongyinju5977 2014-06-27 11:58
    关注

    My localhost is running on a 64bit environment and appspot.com on a 32bit. All numbers smaler then 2147483647 parse ok, but although defined as int64 the id 5838406743490560 is to big to fit into 32bit therefore it get parsed as a string on a appspot.com instance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置