【问题标题】:Best way to embed JSON fields in POST requests for insert into PG using PostgREST使用 PostgREST 在 POST 请求中嵌入 JSON 字段以插入 PG 的最佳方法
【发布时间】:2020-09-25 15:00:50
【问题描述】:

我正在使用 PostgREST 7,并且想在 PostgreSQL 中进行简单的插入操作。我的一个字段是 JSON 字符串,将其插入请求的 JSON 正文会破坏 PostgREST 上的解析。

作为一个使用简单 JSON 字段的示例,请求如下:

curl -k -X POST --header Content-Type: application/json --header Accept: application/json --header Authorization: Bearer asdkfsldkfjsa;kfd;fdj -d {"imagenumber":"12345678", "imagename":"name", "imageversion":"1.0.4.344", "seriousVulnerabilityFound":"false", "report":"{scanResult:{3842483d3c94:{imageId:384241234594,imageSummary:{pass:true}}}}"

是否有支持的方式来编码将在 PostgREST 上解码的 JSON 字符串字段,以便该字段可以作为 JSON 列插入 PG?

【问题讨论】:

    标签: postgrest


    【解决方案1】:

    report 中的值是无效的 json。不要引用它并将其更改为有效的 json:

    {"report": {"scanResult":{"3842483d3c94":{"imageId":384241234594,"imageSummary":{"pass":true}}}}}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2010-09-23
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      相关资源
      最近更新 更多