-
-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
Describe the bug
What's the correct way to access main
and subs
in Jasper Reports if there are multiple objects in JSON?
$extension = 'pdf' ;
$name = 'testeJasper';
$filename = $name . time();
$input = storage_path('app/public/relatorios/invoice.jasper');
$output = base_path('/public/reports/' . $filename);
$array = [
[
"category_id" => "1",
"category_name" => "Module that will allow the pmmed to create a template first before cascading the PIs to offices from VP's OPCR"
],
[
"category_id" => "2",
"category_name" => "Category 2"
],
[
"category_id" => "3",
"category_name" => "Category 3"
]
];
$subReportSource = [
['program' => 'Higher', 'percentage' => '80%'],
['program' => 'Research', 'percentage' => '100%'],
];
$jsonArry = array('data' => ['main' => $array, 'subs' => $subReportSource ]);
$jsonTmpfilePath = storage_path('app/public'). '/relatorios/json/' . $name . '.json';
$jsonTmpfile = fopen($jsonTmpfilePath, 'w');
fwrite($jsonTmpfile, json_encode($jsonArry));
fclose($jsonTmpfile);
$datafile = $jsonTmpfilePath;
$options = [
'format' => ['pdf'],
'params' => [
'msg' => "Display 101",
'storage_path' => storage_path(),
],
'locale' => 'en',
'db_connection' => [
'driver' => 'json',
'data_file' => $datafile,
'json_query' => 'data'
]
];
I tried to put this in my main.jrxml
<queryString language="json">
<![CDATA[data.main]]>
</queryString>
and this one in my subReport.jrxml
<queryString language="json">
<![CDATA[data.subs]]>
</queryString>
Metadata
Metadata
Assignees
Labels
No labels