Informe realizado en JasperSoft Studio no genera bien en código Java

Estoy preparando un informe en JasperSoft Studio usando un JSON como origen de datos, que contiene una matriz al final de la última clave del objeto, con las claves del JSONObject, relleno la banda de detalles del informe y con la otra matriz, relleno una tabla en la banda Resumen, en JasperSoft Studio genera correctamente el informe genera el informe , al generar el informe en código Java utilizando Java 8 utilizando NetBeans como entorno IDE, el informe sólo genera una sola fila con valores Null y no muestra la tabla, adjunto las imágenes y el código Java.

El JSON contiene la siguiente estructura:

{
  "0": {
    "a": "datos1",
    "b": "M-datos2",
    "c": "datos3",
    "d": "datos4",
    "e": "datos5",
    "f": "datos6",
    "g": "2",
    "h": "datos7",
    "i": "$5,000.00",
    "j": "$0.00",
    "k": "$0.00",
    "l": "5000.00",
    "m": "datos8"
  },
  "1": {
    "a": "datos1",
    "b": "M-datos2",
    "c": "datos3",
    "d": "datos4",
    "e": "datos5",
    "f": "datos6",
    "g": "2",
    "h": "datos7",
    "i": "$5,000.00",
    "j": "$0.00",
    "k": "$0.00",
    "l": "5000.00",
    "m": "datos8"
  },
  "2": {
    "a": "datos1",
    "b": "M-datos2",
    "c": "datos3",
    "d": "datos4",
    "e": "datos5",
    "f": "datos6",
    "g": "2",
    "h": "datos7",
    "i": "$5,000.00",
    "j": "$0.00",
    "k": "$0.00",
    "l": "5000.00",
    "m": "datos8"
  },
  "3": {
    "a": "datos1",
    "b": "M-datos2",
    "c": "datos3",
    "d": "datos4",
    "e": "datos5",
    "f": "datos6",
    "g": "2",
    "h": "datos7",
    "i": "$5,000.00",
    "j": "$0.00",
    "k": "$0.00",
    "l": "5000.00",
    "m": "datos8"
  },
  "4": {
    "a": "datos1",
    "b": "M-datos2",
    "c": "datos3",
    "d": "datos4",
    "e": "datos5",
    "f": "datos6",
    "g": "2",
    "h": "datos7",
    "i": "$5,000.00",
    "j": "$0.00",
    "k": "$0.00",
    "l": "5000.00",
    "m": "datos8",
    "sub-totales": [
      {
        "n-mes": "10",
        "sub-total": "13200.00"
      }
    ]
  }
}

JasperSoft Studio genera correctamente la siguiente imagen en su versión 6.15.0

Annex image of the report generated in Java 8 using NetBeans 8.2, where it only shows null values and does not show the table, using the same JSON data source

Annex Java code using to generate the report:

InputStream is;
    is = getClass().getResourceAsStream("/REPORTS/report.jasper");
    Map parameters = new HashMap();
    parameters.put("IMAGE", IMAGE);
    parameters.put("BACKG", BACKG);
    ByteArrayInputStream jsonDataStream = new ByteArrayInputStream(JSON.toString().getBytes());
    JRDataSource ds = new JsonQLDataSource(jsonDataStream);
    JasperReport jr = (JasperReport) JRLoader.loadObject(is);
    JasperPrint jp = JasperFillManager.fillReport(jr, parameters, ds);
    JasperViewer jv = new JasperViewer(jp, false);
    jv.setVisible(true);

I have updated the Java libraries to their latest version but it still doesn't work, I would appreciate your help

hihaji4222's picture
Joined: Jul 12 2020 - 4:58pm
Last seen: 2 years 5 months ago

0 Answers:

No answers yet
Feedback
randomness