manuka | 2019-11-28 17:50:31 UTC | #1
Hey, I've got a question about data action responses. I'm trying to get a list of users from /api/v2/users and saving the users' names and phone numbers into dual arrays for mapping, basic stuff. However, I ran into a problem with null value handling - at the moment my arrays disregard empty values and leave them out of the array, making it impossible to map the 2 arrays together for name - number value pairs, due to the name array having more results.
What I'd like to do is have the response config return something like "NULL" for each empty value and not leave them out, but I cannot figure out how to do this. I've configured the translation map defaults in the response config, but to my understanding, this only returns the "UNKNOWN" value if the entire array is empty;
` { "translationMap": { "name": "$..entities[].name", "msisdn": "$..entities[].addresses[*].address" }, "translationMapDefaults": { "name": "\"UNKNOWN\"", "msisdn": "\"UNKNOWN\"" }, "successTemplate": "{\"name\": ${name}, \"msisdn\": ${msisdn}}" } `
any help with this problem would be appreciated, as well as alternate ways of approaching this. What I'm trying to do is very simple, I just need a list of users and their contact numbers for further operations.
Jason_Mathison | 2019-12-02 13:29:45 UTC | #2
Hi manuka,
Could you provide a representative example of the data you are filtering with your translation map? Feel free to redact / obfuscate names and phone numbers, I just need the right "data shape" to help out.
--Jason
manuka | 2019-12-05 08:52:13 UTC | #3
Hey,
as it is currently, the filtered data would look similar to this;
{ "name": [ "name1", "name2", "name3", "name4", "name5" ], "phoneNumber": [ "phoneNumber1", "phoneNumber2", "phoneNumber4", "phoneNumber5" ] }
in the example above, "name3" does not have a phone number registered in addresses ($..entities[*].addresses[*].address) so it doesn't return a value. What I'm looking for is something like this:
{ "name": [ "name1", "name2", "name3", "name4", "name5" ], "phoneNumber": [ "phoneNumber1", "phoneNumber2", "UNKNOWN", "phoneNumber4", "phoneNumber5" ] }
where the amount of results in the 2nd array always matches the results in the 1st array for mapping reasons.
Thanks,
--Manu
Jason_Mathison | 2019-12-05 13:51:15 UTC | #4
Can you provide a sample of the data prior to it being filtered?
system | 2020-01-05 13:51:19 UTC | #5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 6601