Map JSON object to xValue/yValue

0
I receive the result from a REST GET call in JSON format that looks something like this: {"data": {"result": { "seriesName1": {"<epoch timestamp 1>": <value 1>,"<epoch timestamp 2>": <value 2>,...},{“seriesName2” : {"<epoch timestamp 1>": <value x>,"<epoch timestamp 2>": <value y>,...}}}}}   I want to show the results on charts and I would need to map each timestamp to each value. I tried to create a mapping importing my JOSN file, but it recognizes each key as its own value. Which steps do I need to perform so that I can map the timestamp to an xValue and the value to an yValue attribute of an entity?   Thanks for the support.
asked
1 answers
0

Hi Tiago,

 

Mendix does not handle dynamic keys of key-value pairs. However, there are a couple of options you can try:

  1. You can build your string using a microflow
  2. You can change your JSON structure to the following:
    {
        "data": {
            "result": [
                "seriesName": [
                    "valuesAsString"
                ]
            ]
        }
    }

    You can then store your entire value in valueAsString in your desired format and munipulate the string afterwards

Personally, I would use the first option. It is a pain to test, but once you nailed it down it should be quite solid

answered