Search code examples
azureazure-logic-appsjsonpath

Get value from json in LogicApp


Rephrasing question entirely, as first attempt was unclear.

In my logic app I am reading a .json from blob which contains:

{
    "alpha": {
        "url": "https://linktoalpha.com",
        "meta": "This logic app does job aaaa"
    },
    "beta": {
        "url": "https://linktobeta.com",
        "meta": "This logic app does job beta"
    },
    "theta": {
        "url": "https://linktotheta.com",
        "meta": "This logic app does job theta"
    }
}

I'm triggering the logic app with a http post which contains in the body:

{ "logicappname": "beta" }

But the value for 'logicappname' could be alpha, beta or theta. I now need to set a variable which contains the url value for 'beta'. How can this be achieved without jsonpath support?

I am already json parsing the file contents from the blob and this IS giving me the tokens... but I cannot see how to select the value I need. Would appreciate any assistance, thank you.


Solution

  • For your requirement, I think just use "Parse JSON" action to do it. Please refer to the steps below:

    1. I upload a file testJson.json to my blob storage, then get it and parse it in my logic app. enter image description here

    2. We can see there are three url in the screenshot below. As you want to get the url value for beta, it is the second one, so we can choose the second one. enter image description here

    If you want to get the url value by the param logicappname from the "When a HTTP request is received" trigger, you can use a expression when you create the result variable. enter image description here

    In my screenshot, the expression is:

    body('Parse_JSON')?[triggerBody()?['logicappname']]?['url']
    

    As the description of your question is a little unclear and I'm confused about the meaning of I am already json parsing the file contents from the blob and this IS giving me the tokens, why is "tokens" involved in it ? And in the original question it seems you want to do it by jsonpath but in the latest description you said without jsonpath ? So if I misunderstand your question, please let me know. Thanks.