Need to split data based on separators and display in a chart

0
I am using a microflow to call my REST service. I have created a Mapping and a JSON_Structure as well.  All is fine with this, but the actual values I need from my JSON are / and | separated.   This is an example of the data being returned from my API [ { "_id": "633610ea29cc82363d675f0f", "metric": "dailyAvgMosScore", "value": "4.20/4.22/4.50|3.50/4.19/4.30", "date": "20220928", "createdAt": "2022-09-29T21:40:58.526Z", "updatedAt": "2022-09-29T21:40:58.526Z", "__v": 0 }, { "_id": "633610eb29cc82363d675f13", "metric": "dailyAvgMosScore", "value": "1.00/4.21/4.50|1.00/4.13/4.40", "date": "20220929", "createdAt": "2022-09-29T21:40:59.467Z", "updatedAt": "2022-09-29T21:40:59.467Z", "__v": 0 } ]   My Goal My goal is to take the “value” field and split that up and display it in a multi line chart.   Group mapping: Listen Quality & Call Quality (PIPE separated) Value mapping: “low,avg,high” | “low,avg,high”   If this were JS, I would have done this, but I don’t know how to translate this to Mendix (I am brand new) let newData = []; for(const row of list){ const mainSplit = row.value.split('|') newData.push({ lowestMOSLQ: mainSplit[0].split('/')[0], averageMOSLQ: mainSplit[0].split('/')[1], highestMOSLQ: mainSplit[0].split('/')[2], lowestMOSCQ: mainSplit[1].split('/')[0], averageMOSCQ: mainSplit[1].split('/')[1], highestMOSCQ: mainSplit[1].split('/')[2], date: row.date }) } return newData;   I hope I was clear!
asked
1 answers
0

Hi Alan,

Welcome to Mendix. Lovely to have you here. If you can change your API  to reply pure json, than that would be easiest solution. But very likely you have your reasons for returning the structure in this way. To separate the string you can download CommunityCommons from the marketplace and use the widget StringSplit.

Best regards. 

answered