液体中的空间处理程序不起作用
我无法弄清楚如何从字符串的开始和结尾处删除空格。
我的响应主体是:
{
"value": [
{
"nomeUnidadeOperacional": " ",
"nomeCaixaPostalComunitaria": " ",
"nroCaixaPostal": " ",
"enderecoCaixapostal": " "
}
]
}
我尝试使用“ | split”和“ {% - 分配item = body.value [0] - %}”作为液体文档说明“空间控制”。
我的固定体:
<set-body template="liquid">
{
"Endereco": {
{% assign item = body.value[0] %}
"caixaPostal": {
"nome": "{{item.nomeCaixaPostalComunitaria | strip }}",
"numero": "{{item.nroCaixaPostal | strip }}",
"endereco": "{{item.enderecoCaixapostal | strip }}"
}
}
}
</set-body>
我得到的:
{
"Endereco": {
"caixaPostal": {
"nome": " ",
"numero": " ",
"endereco": " "
}
}
}
我期望的是:
{
"Endereco": {
"caixaPostal": {
"nome": "",
"numero": "",
"endereco": ""
}
}
}
确保可以使用IF测试内容是否为“”并在此之后替换,但是我可以拥有1个以上的空间,并且此选项并不优雅。
I cannot figure out how to remove whitespaces from the start and end of my strings.
My response body is:
{
"value": [
{
"nomeUnidadeOperacional": " ",
"nomeCaixaPostalComunitaria": " ",
"nroCaixaPostal": " ",
"enderecoCaixapostal": " "
}
]
}
I tried using "| split" and "{%- assign item = body.value[0] -%}" as the documentation for liquid explain "whitespace control".
My set-body:
<set-body template="liquid">
{
"Endereco": {
{% assign item = body.value[0] %}
"caixaPostal": {
"nome": "{{item.nomeCaixaPostalComunitaria | strip }}",
"numero": "{{item.nroCaixaPostal | strip }}",
"endereco": "{{item.enderecoCaixapostal | strip }}"
}
}
}
</set-body>
What I'm getting:
{
"Endereco": {
"caixaPostal": {
"nome": " ",
"numero": " ",
"endereco": " "
}
}
}
What I expected:
{
"Endereco": {
"caixaPostal": {
"nome": "",
"numero": "",
"endereco": ""
}
}
}
Sure i could use a if to test if the content is " " and replace it after, but i could have more than 1 whitespace and this option isn't elegant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在API管理上,您需要编写大写的过滤器。
On API Management you need to write the Filter Capitalized.