Azure 表无法存储扁平化 JSON

Azure tables unable to store flattened JSON

我正在使用 npm flat 包,arrays/objects 被展平,但是 object/array 键被 '' 包围,就像在 'task_status.0.data' 中使用下面的对象.

这些特定字段不会存储到 AzureTables - 其他字段会存储,但这些字段会被默默地忽略。我该如何解决这个问题?

var obj1 = {
    "studentId": "abc",
    "task_status": [
            {
                "status":"Current",
                "date":516760078
            },
            {
                "status":"Late",
                "date":1516414446
            }
        ],
    "student_plan": "n"
 }

以下是我的使用方式 - 简化代码示例:同样,它成功写入 table,但不会写入被展平的属性(见下文):

var flatten = require('flat')
newObj1 = flatten(obj1);
var entGen = azure.TableUtilities.entityGenerator;
newObj1.PartitionKey = entGen.String(uniqueIDFromMyDB);
newObj1.RowKey = entGen.String(uniqueStudentId);
tableService.insertEntity(myTableName, newObj1, myCallbackFunc);

在上面的例子中,展平的对象看起来像:

var obj1 = {
    studentId: "abc",
    'task_status.0.status': 'Current',
    'task_status.0.date': 516760078,
    'task_status.1.status': 'Late',
    'task_status.1.date': 516760078,
    student_plan: "n"
 }

然后我会添加 PartitionKey 和 RowKey。

所有 task_status 字段将无法插入。

编辑:这与实际的展平过程没有任何关系 - 我刚刚检查了一个非常好的 JSON 对象,其中包含 'x.y.z' 的键,即 AzureTables 没有似乎接受这些列名....这几乎完全破坏了存储无模式数据的价值主张,而无需进行重大返工。

不支持列名称中的

.。您可以 use a custom delimiter 来展平您的对象。

例如:

newObj1 = flatten(obj1, {delimiter: '__'});