简体   繁体   English

JSON int密钥发布数据e2e(寻找对象密钥字符串开头的无效字符“ 1”)

[英]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.

相关问题 JSON无效字符'}'正在寻找对象键字符串的开头 - JSON invalid character '}' looking for beginning of object key string json 格式无效,请检查。 原因:寻找对象键字符串开头的无效字符“a” - Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string JSON无法写入创世纪块:无效字符'\\\\'寻找对象密钥字符串的开头 - JSON failed to write genesis block: invalid character '\\' looking for beginning of object key string Xamarin&Golang-{[]}无效字符'\\ x00'寻找对象密钥字符串的开头 - Xamarin & Golang - { []} invalid character '\x00' looking for beginning of object key string 在 Json Curl 上使用生成的 PHP 字符串获取“无效的关键字符” - Getting "Invalid Key Character" With generated PHP string on Json Curl NestJS 在 e2e 中返回缓冲区而不是 JSON - NestJS returns buffer instead of JSON in e2e Golang无效字符'b'寻找值的开始 - Golang invalid character 'b' looking for beginning of value 解析整个JSON对象以寻找python中的键 - Parse an entire JSON object looking for a key in python 对象键后面的字符无效-geojson中的对象键是什么? - Invalid character after object key - What is an object key in geojson? 无论如何他们是要使 json 对象模式固定,即始终包含相同的键 - Is their is anyway to make json object schema fixed i.e always contains same key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM