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 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题