LogicApp – 更改 JSON

huangapple go评论45阅读模式
英文:

LogicApp - Changing JSON

问题

以下是您提供的JSON数据的转换结果:

[
  {
    "An Id": 123,
    "Full Name": "John Doe",
    "New Field Added": "A value which is new"
  },
  {
    "An Id": 124,
    "Full Name": "James Deen",
    "New Field Added": "A new value"
  }
]

希望这有助于您解决问题。如果您需要更多帮助,请随时提问。

英文:

I have some JSON like this produced from a step in the LogicApp I am working on.

[
  {
    "id": 123,
    "displayName": "John Doe",
    "firstName": "John",
    "lastName": "Doe",
    "gender": "Male",
    "jobTitle": "Customer Service Representative",
    "workPhone": "555-555-5555",
    "workPhoneExtension": null,
    "skypeUsername": "JohnDoe",
    "facebook": "JohnDoeFacebook"
  },
  {
    "id": 124,
    "displayName": "James Deen",
    "firstName": "James",
    "lastName": "Deen",
    "gender": "Male",
    "jobTitle": "Job Title",
    "workPhone": "555-555-5555",
    "workPhoneExtension": null,
    "skypeUsername": "JamesDean",
    "facebook": "JamesDeenFacebook"
  }
]

I was hoping the use of the SELECT component would allow me to exclude fields and essentially rename fields.

How would I transform the above JSON into the following?

[
  {
    "An Id": 123,
    "Full Name": "John Doe",
    "New Field Added", "A value which is new"
  },
  {
    "An Id": 124,
    "Full Name": "James Deen",
    "New Field Added", "A new value"
  }
]

At the moment, I am getting issues with FOREACH components being added. I have also used FOREACH loops and various ways to achieve this change.

Would very much appreciate someone explaining the best way to do this.

For example with a SELECT added with one field mapped I see
LogicApp – 更改 JSON

When adding another it adds a foreach changes things.

Many thanks in advance

答案1

得分: 0

答案是因为我选择了不正确的"from"值。在字段列表中,我包含了JSON中的每个字段,还包括包含值的数组名称,以及一个'body'项目。

当您选择数组名称,比如employees时,它会出现问题,但如果您使用body项目,它会正常工作。

英文:

The answer is because I was choosing the incorrect from value. In the list of fields I had each field from the JSON, plus the array name holding the values, plus the a 'body' item.

It goes wrong when you select the array name , in this case employees but if you use the body item, it works properly.

LogicApp – 更改 JSON

huangapple
  • 本文由 发表于 2023年3月31日 19:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897931.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定