Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Translation map problems

    Posted 06-05-2025 18:43

    Smikel | 2022-09-14 16:05:46 UTC | #1

    I have made a api request for finding out if any earlier callback has been ordered by the same customer, to avoid multiple callback. However i got the result back properly.

    { "results": [ { "group": { "mediaType": "callback" }, "data": [ { "interval": "2022-09-01T13:20:00.000Z/2022-09-01T13:35:00.000Z", "metrics": [ { "metric": "nOffered", "stats": { "count": 1 } } ] } ] } ] }

    But i can't get it to work with the translation map. I want to extract "count": 1 My translation which doesn't work:

    { "translationMap": { "count": "$.result[].data[].metrics[*].stats.count" }, "translationMapDefaults": {}, "successTemplate": "{ \"count\": ${count}" }

    Can somebody tell me what i', doing wrong ..


    Jason_Mathison | 2022-09-14 16:07:42 UTC | #2

    Hi Smikel,

    FYI, I edited your post to make your two JSON blobs look right. I made sure that there was an empty line on both sides of them and then highlighted them and hit the </> button to retain your original formatting and not hide any characters.

    If you put your response and translation map entry into

    http://jsonpath.herokuapp.com/

    I believe that you will quickly figure out what the issue is.

    --Jason


    Smikel | 2022-09-15 09:33:23 UTC | #3

    Thanks, well i had to test my way towards a solution. But it works now. A correct response with translation map should look like this. If someone else is interested and wonder what works. {

    "translationMap": {

    "count": "$.results[0].data[0].metrics[0].stats.count"

    },

    "translationMapDefaults": {

    "count": "0"

    },

    "successTemplate": "{ \"count\" : ${count} }"

    }


    John_Carnell | 2022-09-16 12:34:40 UTC | #4


    This post was migrated from the old Developer Forum.

    ref: 16290