jasper: listing all key-values pairs of a collection
In jasper I have to print a collection without knowing in advance the keys, because they are programmatic and can change over time. Let me do an example of this list:
- formData[0]={addictions=1, workout=0, allergies=1, selfSufficiency=0}
- formData[1]={gastricNose=1, weightChange=1, diet=XXXX}
- [...]
- formData[12]={dailyAmount=12, latestDate={type=date, value=1542582000000}, ostomy=1, ostomyType=AA, ostomyBag=BB}
How can I print a list of all these keys/values so that they get all listed properly like this? I can already print these objects raw in a list but they obviously look pretty much like the example I wrote above, while instead I need jasper to cycle through each of the elements by itself and retrieve the keys and the value for each element.
This is what I'm trying to print:
- addictions: 1
- workout: 0
[...]
gastricNose: 1
- weightChange: 1
[...]
dailyAmount: 12
- latestDate: 18/11/2018
- [...]
In all posts I've looked into I'm required to know at least the name of the keys, but in my case I can't. And I cannot modify the data source structure either (for instance formatting the collection to be {key:"addictions",value:"1"} can't do that).
Thanks for your hints
jasper-reports
add a comment |
In jasper I have to print a collection without knowing in advance the keys, because they are programmatic and can change over time. Let me do an example of this list:
- formData[0]={addictions=1, workout=0, allergies=1, selfSufficiency=0}
- formData[1]={gastricNose=1, weightChange=1, diet=XXXX}
- [...]
- formData[12]={dailyAmount=12, latestDate={type=date, value=1542582000000}, ostomy=1, ostomyType=AA, ostomyBag=BB}
How can I print a list of all these keys/values so that they get all listed properly like this? I can already print these objects raw in a list but they obviously look pretty much like the example I wrote above, while instead I need jasper to cycle through each of the elements by itself and retrieve the keys and the value for each element.
This is what I'm trying to print:
- addictions: 1
- workout: 0
[...]
gastricNose: 1
- weightChange: 1
[...]
dailyAmount: 12
- latestDate: 18/11/2018
- [...]
In all posts I've looked into I'm required to know at least the name of the keys, but in my case I can't. And I cannot modify the data source structure either (for instance formatting the collection to be {key:"addictions",value:"1"} can't do that).
Thanks for your hints
jasper-reports
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53
add a comment |
In jasper I have to print a collection without knowing in advance the keys, because they are programmatic and can change over time. Let me do an example of this list:
- formData[0]={addictions=1, workout=0, allergies=1, selfSufficiency=0}
- formData[1]={gastricNose=1, weightChange=1, diet=XXXX}
- [...]
- formData[12]={dailyAmount=12, latestDate={type=date, value=1542582000000}, ostomy=1, ostomyType=AA, ostomyBag=BB}
How can I print a list of all these keys/values so that they get all listed properly like this? I can already print these objects raw in a list but they obviously look pretty much like the example I wrote above, while instead I need jasper to cycle through each of the elements by itself and retrieve the keys and the value for each element.
This is what I'm trying to print:
- addictions: 1
- workout: 0
[...]
gastricNose: 1
- weightChange: 1
[...]
dailyAmount: 12
- latestDate: 18/11/2018
- [...]
In all posts I've looked into I'm required to know at least the name of the keys, but in my case I can't. And I cannot modify the data source structure either (for instance formatting the collection to be {key:"addictions",value:"1"} can't do that).
Thanks for your hints
jasper-reports
In jasper I have to print a collection without knowing in advance the keys, because they are programmatic and can change over time. Let me do an example of this list:
- formData[0]={addictions=1, workout=0, allergies=1, selfSufficiency=0}
- formData[1]={gastricNose=1, weightChange=1, diet=XXXX}
- [...]
- formData[12]={dailyAmount=12, latestDate={type=date, value=1542582000000}, ostomy=1, ostomyType=AA, ostomyBag=BB}
How can I print a list of all these keys/values so that they get all listed properly like this? I can already print these objects raw in a list but they obviously look pretty much like the example I wrote above, while instead I need jasper to cycle through each of the elements by itself and retrieve the keys and the value for each element.
This is what I'm trying to print:
- addictions: 1
- workout: 0
[...]
gastricNose: 1
- weightChange: 1
[...]
dailyAmount: 12
- latestDate: 18/11/2018
- [...]
In all posts I've looked into I'm required to know at least the name of the keys, but in my case I can't. And I cannot modify the data source structure either (for instance formatting the collection to be {key:"addictions",value:"1"} can't do that).
Thanks for your hints
jasper-reports
jasper-reports
edited Nov 21 '18 at 17:27
Alex K
18.3k1479153
18.3k1479153
asked Nov 21 '18 at 10:44
nohup
42
42
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53
add a comment |
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410366%2fjasper-listing-all-key-values-pairs-of-a-collection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410366%2fjasper-listing-all-key-values-pairs-of-a-collection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
One way is to create a method in java that takes the json which return a JRDatasource, hence you call this from jasper.
– Petter Friberg
Nov 21 '18 at 15:50
Do you mean a java class embedded somehow in jaspersoft studio, then built all together?
– nohup
Nov 21 '18 at 16:00
Yes exactly a class that supply the datasource you need
– Petter Friberg
Nov 21 '18 at 16:05
The existing backend application is already feeding the report with this data and I cannot change it. I can only twiddle with jaspersoft studio. Unless there is a way to pack a java class into a jasper report to "modify" the incoming datasource that being almost a total jasper noob I'm not aware of.
– nohup
Nov 22 '18 at 7:53