Legacy Dev Forum Posts

 View Only

Sign Up

Data Action - response that includes $

  • 1.  Data Action - response that includes $

    Posted 06-05-2025 19:22

    lukefmitchell | 2022-08-02 12:28:07 UTC | #1

    Hi All,

    We are trying to retrieve data from a dat action when the child element is labelled "$", currently attempting this fails.

    Example response (Appreciate this is not the full response but a snippet as example):

    { "secureDataReadResponse": { "sessionData": { "entry": [ { "@name": "Group.Req", "$": "false" }, { "@name": "Group.Length", "$": "3" },

    So for example we are trying to capture the "$":"false" and use the false value in architect

    Have tried the below but it doesnt seem to work: $.secureDataReadResponse.sessionData.entry[1].$

    Is this possible?

    Thanks Luke


    Jason_Mathison | 2022-08-02 13:30:54 UTC | #2

    Hey Luke,

    The only problem I could find is that you have entry[1] instead of entry[0]. Arrays are indexed off of 0 instead of 1.

    To get there I first put in your JSON example into jsonline.com and added ] and } until it was valid JSON

    { "secureDataReadResponse": { "sessionData": { "entry": [{ "@name": "Group.Req", "$": "false" }, { "@name": "Group.Length", "$": "3" } ] } } }

    The I put that into http://jsonpath.herokuapp.com/ and used your JSON path, which returned "3". Changing your entry[1] to 0 instead returned "false"

    --Jason


    Jerome.Saint-Marc | 2022-08-02 13:47:17 UTC | #3

    Hello,

    if you are trying to capture the "$":"false", it is the item with index 0 (entry[1] corresponds to the item with "$": "3").

    You can use the following: "$.secureDataReadResponse.sessionData.entry[0].[\"$\"]"

    Just for sake of fun :slight_smile: You can also get the value searching on @name == Group.Req instead of using static index for it. Something like:

    { "translationMap": { "capturedValuesAsArray": "$.secureDataReadResponse.sessionData.entry[?(@.[\"@name\"] ==\"Group.Req\")].[\"$\"]" }, "translationMapDefaults": { "capturedValuesAsArray": "[]" }, "successTemplate": "{\"value\": ${successTemplateUtils.firstFromArray(\"${capturedValuesAsArray}\", \"${esc.quote}NOTFOUND${esc.quote}\")} }" }

    Regards,


    lukefmitchell | 2022-08-02 13:51:32 UTC | #4

    Thank you both,

    Appologies I was using 1 for the array

    Jerome, thank you very much, that was the issue I was facing, how to put the $ into the response, that worked perfectly.

    Thank you both for your help!


    John_Carnell | 2022-08-08 13:16:04 UTC | #5


    This post was migrated from the old Developer Forum.

    ref: 15759