[英]JSON int key issue data e2e (invalid character '1' looking for beginning of object key string)
My app uses aerospike to store Map in one of the bins, I am use endly for e2e testing, which uses JSON for data representation: 我的应用程序使用Aerospike将Map存储在其中一个容器中 , 最终用于e2e测试,该测试使用JSON进行数据表示:
How do to populate datastore with with JSON where key needs to be an int ? 如何在密钥需要为int的情况下使用JSON填充数据存储区? Since json does not allowed int key I am getting the following error: invalid character '1' looking for beginning of object key string 由于json不允许使用int密钥,因此出现以下错误:无效字符'1'寻找对象密钥字符串的开头
Here is my data workflow (invoked by regression workflow) 这是我的数据工作流程(由回归工作流程调用)
@data.yaml @ data.yaml
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
Here is my use case level data: 这是我的用例级别的数据:
@mydaaset.json @ mydaaset.json
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
1191: "$timestamp.yesterday",
1192: "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
In your example @mydaaset.json file is invalid JSON, thus you getting 在您的示例中,@ mydaaset.json文件是无效的JSON,因此您得到
'invalid character '1' looking for beginning of object key string'
parsing error 解析错误
In order to pre-seed your use case test data in aerospike with map[int]int bin you can use AsInt UDF 为了使用map [int] int bin在Aerospike中预先植入用例测试数据,可以使用AsInt UDF
@mydaaset.json @ mydaaset.json
[
{
"Table": "myDataset",
"Value": [{
"id": "$id",
"created": "$timestamp.yesterday",
"fc":{
"$AsInt(1191)": "$timestamp.yesterday",
"$AsInt(1192)": "$timestamp.now",
}
}],
"AutoGenerate": {
"id": "uuid.next"
},
"Key": "${tagId}_myDataset"
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.