解析nbd.键(urlsafe=string)外部

2024-04-27 16:06:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我再往前走一点。我在googleapps脚本中得到一个用nbd.键()在python中。你知道吗

当我解码这个密钥时,我得到一组不完整的数据:

agxzfm92ZXItc2lnaHRyJwsSCEN1c3RvbWVyIghzeXNhZG1pbgwLEglDb25kaXRpb24YpJwBDA

当我把它转换回来时,我得到了可读的实体,但是我错过了ID。这是base64解码:

"js~over-sightr'Customer"sysadmin   Condition��"

有没有一种不需要Python就能把所有东西都拿回来的方法?你知道吗

旧职位:

In Google Datastore, a set of scores is saved to the DataStore as nbd.jsonProperty.

I can parse this in Google Apps Script, and I get a set of data. Now I find for each element the following structure:

[
 {"not_applicable":false,
  "key":"aghxxxxxxxxxxIUXVlc3Rpb24YgICAgPjChAoM",
  "given_score":0
 },
 ...
]

The key here, I can base64decode. I see that I find the related question information (the key points to another entity). It shows a

char+datastoreId+char+kind+?I expect the key here?

Exept, how can I get that last part? The base64 decoder gives stange characters for that last part, but I suspect there is the ID as a number in there.

I am using Google Apps Script. Can I get this ID from this encoded string? I cannot post the whole string, but the last part of the byte array is [-128, -128, -128, -8, -62, -124, 10, 12] and I suspect this represents the ID.

Any ideas or experience?


Tags: ofthekeyidgetthatisgoogle
1条回答
网友
1楼 · 发布于 2024-04-27 16:06:31

URLSafe密钥(特定于Python客户机库)是实体密钥的内部protobuf v1表示形式的Base64编码版本。它不是被设计成外部解码的。你知道吗

我不认为Apps脚本有一个简单的方法来使用protobuf消息,但是理论上你可以通过看NDB实现结合理解协议缓冲区如何编码数据来实现它。你知道吗

相关问题 更多 >