0

我正在使用 API 调用content.deidentify对文本内容进行去标识化。它按预期工作,但换行符被剥离。

API 调用

curl -s \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  https://dlp.googleapis.com/v2/projects/$PROJECT_ID/content:deidentify \
  -d @text-request.json \
  > text-response.json

输入

Eleanor Rigby 
Pharmacist 
Liverpool Hospital 
eleanor.rigby@example.com

输出

{
  "item": {
    "value": "Eleanor Rigby Pharmacist Liverpool Hospital [email-address]"
  },
  "overview": {
    ...
  }
}

我可以在请求中添加任何选项以保留换行符吗?

setPrettyPrint在 Java 客户端文档中找到了。直接调用 API 时可以使用该选项吗?

4

1 回答 1

1

该问题与 DLP 无关。

我发送了无效的 JSON

{
    "item": {
        "value": "Eleanor Rigby 
Pharmacist 
Liverpool Hospital 
eleanor.rigby@example.com"
    },
    "deidentifyConfig": {
        ...
    }
}

用换行符替换\n问题解决了。

于 2020-11-19T19:10:04.447 回答