Bug 26286

Summary: Add option to use JSON objects rather than JSON arrays for public reports
Product: Koha Reporter: David Cook <dcook>
Component: ReportsAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description David Cook 2020-08-24 02:33:58 UTC
At the moment, /cgi-bin/koha/svc/report outputs a JSON array of JSON arrays. It would be better to output a JSON array of JSON objects.

Currently, you have to know the index position of the column you want. If you change your report, you can easily break your API consumer logic. 

In the future, you could use the column name as the object key. This means that you could update your report with a new column, and so long as you keep the other column names the same, your existing API consumer would work fine.
Comment 1 David Cook 2020-08-24 02:34:21 UTC
Also, unless you're the writer of the report, it's impossible to know what data you're working with when using a JSON array of JSON arrays.
Comment 2 Katrin Fischer 2020-08-24 06:27:27 UTC
You an use the annotated operator, then you can use the names.
Comment 3 Katrin Fischer 2020-08-24 06:28:15 UTC
(In reply to Katrin Fischer from comment #2)
> You an use the annotated operator, then you can use the names.

bug 11491
Comment 4 David Cook 2020-08-24 07:14:12 UTC
(In reply to Katrin Fischer from comment #2)
> You an use the annotated operator, then you can use the names.

Interesting. I'd never heard of that before. That looks like just the thing.
Comment 5 David Cook 2020-08-24 07:14:23 UTC

*** This bug has been marked as a duplicate of bug 11491 ***