英文:
I need to pick a specific value from an array
问题
"body": {
"ShipmentResponse": {
"Notification": [
{
"@code": "0",
"Message": null
}
],
"PackagesResult": {
"PackageResult": [
{
"number": ,
"TrackingNumber":
},
{
"number":,
"TrackingNumber":
}
]
},
"LabelImage": [
{
"LabelImageFormat": "PDF",
"GraphicImage": "Value required"
}
]
}
}
从上面的响应中,我只需要提取GraphicImage的值。
我尝试使用一个数组变量和筛选数组,但LabelImageFormat和GraphicImage被视为一个单一的索引,因此我无法提取单个值。
请告诉我如何只提取所需的值,即GraphicImage。
"GraphicImage": "Value required"
提前感谢。
英文:
I have an output response from the HTTP request as shown below
"body": {
"ShipmentResponse": {
"Notification": [
{
"@code": "0",
"Message": null
}
],
"PackagesResult": {
"PackageResult": [
{
"number": ,
"TrackingNumber":
},
{
"number":,
"TrackingNumber":
}
]
},
"LabelImage": [
{
"LabelImageFormat": "PDF",
"GraphicImage": "Value required"
}
],
From the above response I need to fetch only the GraphicImage value.
I tried by using a array variable anf Filter array but LabelImageFormat and Graphic Image is treated as one single Index, as a result of which I am unable to fetch a single value.
Please let me know how I can fetch only the value required that is Graphic Image.
"GraphicImage": "Value required"
Thanks in Advance
答案1
得分: 0
这应该很容易使用ParseJson操作。
-
解析JSON:
收到HTTP响应后,添加一个'Parse JSON'操作。
对于内容,提供HTTP响应的正文(例如,
outputs('HTTP_action_name').body
)。对于模式,您可以使用您提供的示例负载来生成它。
-
提取
GraphicImage
的值:在解析JSON后,您可以通过'Parse JSON'操作的输出直接访问
GraphicImage
的值。添加一个新的操作(如'Set variable'或'Compose'),其值使用以下表达式:
outputs('Parse_JSON_action_name')?['body/ShipmentResponse/LabelImage'][0]?['GraphicImage']
将
Parse_JSON_action_name
替换为您的'Parse JSON'操作的名称。 -
使用该值:
在上述步骤之后,GraphicImage的值将存储在变量或Compose操作中。然后,您可以根据需要在您的Logic App的后续步骤中使用它。
英文:
This should be easy with ParseJson Action.
-
Parse the JSON:
After receiving the HTTP response, add a 'Parse JSON' action.
For the content, provide the body of the HTTP response (e.g.,
outputs('HTTP_action_name').body
).For the schema, you can use the sample payload you provided to generate it.
-
Extract the
GraphicImage
Value:After parsing the JSON, you can access the
GraphicImage
value directly through the outputs of the 'Parse JSON' action.Add a new action (like 'Set variable' or 'Compose') and for its value, use the following expression:
outputs('Parse_JSON_action_name')?['body/ShipmentResponse/LabelImage'][0]?['GraphicImage']
Replace
Parse_JSON_action_name
with the name of your 'Parse JSON' action. -
Use the Value:
After the above step, the GraphicImage's value will be stored in the variable or the Compose action. You can then use it in subsequent steps of your Logic App as needed.
答案2
得分: 0
个人认为这将是最简单的方法...
first(body('HTTP')['ShipmentResponse']['LabelImage'])['GraphicImage']
...注意到你的HTTP操作被命名为 HTTP
。
英文:
Personally I think this would be the easiest approach ...
first(body('HTTP')['ShipmentResponse']['LabelImage'])?['GraphicImage']
... noting that your HTTP operation is named HTTP
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论