Category: | Enhancement request |
Priority: | Normal |
Status: | Feedback Requested |
Project: | Severity: | Minor |
Resolution: | Works as Designed |
|
Component: | Reproducibility: | N/A |
Assigned to: |
After importing a file in JSON-LD format (from Omeka S, in my case) it is necessary to incorporate Java expressions to filter the delimiting characters, that is, brackets and quotation marks (["and"]) at the beginning and end of the fields, and quotes (") delimiting multiple fields.
Would it be possible to have a simple option that avoids these characters? I am a Jaspersoft Studio Community 6.16.0 user.
Excuse my English. Thank you first of all for your effort and work.
v6.16
Data Adapters
6 Comments:
Hi,
Not being very familiar with JSON-LD, I can't say exactly what the requirement is.
Maybe you can provide more details about what you need to achieve and give some examples to better understand.
Thank you,
Teodor
Hi, Teodord. Public specifications are here: https://json-ld.org/ And for Omeka S: https://omeka.org/s/docs/developer/api/rest_api_reference/ An example: https://birgitta.test.uib.no/s/birgitta/item/214.json-ld (from: https://birgitta.test.uib.no/s/birgitta/item/214)
In Jaspersoft Studio I need this expression in every field:
$F{FIELD}.replace("\"", "").replace("[", "").replace("]", "").replace(",", "; ")
And before import file, I must do a search and replace:
\" by '
\n by <br>
"," by <br>
Thanks for your answer. Greetings.
Could you post a sample JRXML and JSON to reproduce the issue?
I attach the file. The password is "prueba" (without the quotes). Thank you for your attention. Greetings
You are getting all your textfields wrapped in '["' because all your property expressions produce arrays.
For instance, in "Titulo" field:
<property name="net.sf.jasperreports.json.field.expression" value="dcterms:title.@value"/>
produces an array because your JSON key "dcterms:title" is an array with one element.
If at that key there is always going to be an array with one element, you could have your expression like so:
<property name="net.sf.jasperreports.json.field.expression" value="dcterms:title.@value[0]"/>
and you would not have to substring that field's value to remove the surrounding brackets and quotes.
For those arrays that have more than one element, like in the case of the "Soporte o materia" field:
<property name="net.sf.jasperreports.json.field.expression" value="dcterms:medium.o:label"/>
the recommended solution would be to iterate over those elements with a list component, like described here:
https://stackoverflow.com/a/39568989/5882963
Thank you very much, Narcism, I will modify my report according to what you tell me. I appreciate your help.