我想创建一个(json)文件manuyll(使用python)并将其与谷物一起加载到我的c++应用程序中。
使用 ceral 保存和加载工作正常。但是,我不清楚 json 文件中的 polymorphic_ids。
这里有一个更清晰的例子:这是由谷类框架生成的对象:```
{
"array1": [
{
"key": 0,
"value": {
"ptr_wrapper": {
"id": 2147483649, //!-- ID1
"data": {
...some float fields...
}
}
}
},
{
"key": 1,
"value": {
"ptr_wrapper": {
"id": 2147483650, //!-- This is previous ID+1 and so on...
"data": {
... some float fields...
}
}
}
}
],
"array2": [
{
"key": 0,
"value": {
"polymorphic_id": 2147483649, //!-- this is the very first ID from array 1.
"polymorphic_name": "my_struct_name",
"ptr_wrapper": {
"id": 2147483651, //this ID1+N Elements from array1
"data": {
... also some float stuff...
}
}
}
}
]
}
```
当我观察数字生成时,第一个 ID 增加了。第二个数组使用第一个 ID 作为其多态 ID,并进一步增加数字。
那么为什么使用这些数字有什么逻辑吗?一直使用它们是否可以节省,或者当我在另一台机器上运行我的 c++ 导入器时这些会改变?