I have json file:
{
"apples": [
{"yellow":2},
{"red":5},
{"green":10}
]
}
I'm trying to create a table in "Jaspersoft studio", however I'm facing a problem with dataset for table when creating it. It only allows to choose one object from array, not the whole array. What am I doing wrong? Here are screenshots:
The problem is that your json datasource is incorrect, it does not have a correct structure that can be easily used by any system trying to parse it, since the properties are not know but instead dynamic.
It should have been something like this:
[
{"color": "yellow","number": 2},
{"color": "red","number": 5},
{"color": "green","number": 10}
]
What you should do now is to teach the providers of this datasource to create a correct and usable json, if this is impossibile and you are stuck with this random text, I would probably use java to restructure it. Use a json parser and as you encounter tokens add the data in a structured way to a list of objects, then pass this list of objects to jasper report.