JSON int密钥问题数据e2e(查找对象密钥字符串开头的无效字符';1')
我的应用程序使用aerospike将地图存储在其中一个箱子中, 我用于e2e测试,它使用JSON表示数据: 如何使用JSON填充数据存储,其中键需要是int? 由于json不允许int键,我得到以下错误:无效字符“1”查找对象键字符串的开头 这是我的数据工作流(由回归工作流调用) @data.yamlJSON int密钥问题数据e2e(查找对象密钥字符串开头的无效字符';1'),json,integration-testing,aerospike,end-to-end,endly,Json,Integration Testing,Aerospike,End To End,Endly,我的应用程序使用aerospike将地图存储在其中一个箱子中, 我用于e2e测试,它使用JSON表示数据: 如何使用JSON填充数据存储,其中键需要是int? 由于json不允许int键,我得到以下错误:无效字符“1”查找对象键字符串的开头 这是我的数据工作流(由回归工作流调用) @data.yaml defaults: datastore: db1 pipeline: register: action: dsunit:register config: drive
defaults:
datastore: db1
pipeline:
register:
action: dsunit:register
config:
driverName: aerospike
descriptor: "tcp([host]:3000)/[namespace]"
parameters:
dbname: db1
namespace: test
host: 127.0.0.1
port: 3000
dateFormat: yyyy-MM-dd hh:mm:ss
prepare:
data:
action: nop
init:
- key = data.db.mydaaset
- mydaaset = $AsTableRecords($key)
setup:
action: dsunit:prepare
URL: regression/db1/data/
data: $mydaaset
以下是我的用例级数据:
@mydaaset.json
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
1191: "$timestamp.yesterday",
1192: "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
"$AsInt(1191)": "$timestamp.yesterday",
"$AsInt(1192)": "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
在您的示例中,@mydaaset.json文件是无效的json,因此
'invalid character '1' looking for beginning of object key string'
解析错误
为了使用map[int]int bin在aerospike中预先设定用例测试数据的种子,您可以使用AsInt UDF
@mydaaset.json
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
1191: "$timestamp.yesterday",
1192: "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
"$AsInt(1191)": "$timestamp.yesterday",
"$AsInt(1192)": "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
在您的示例中,@mydaaset.json文件是无效的json,因此
'invalid character '1' looking for beginning of object key string'
解析错误
为了使用map[int]int bin在aerospike中预先设定用例测试数据的种子,您可以使用AsInt UDF
@mydaaset.json
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
1191: "$timestamp.yesterday",
1192: "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
"$AsInt(1191)": "$timestamp.yesterday",
"$AsInt(1192)": "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]