https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40383

--- Comment #25 from Kyle M Hall (khall) <[email protected]> ---
Created attachment 193057
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=193057&action=edit
Bug 40383: Add JSON representation to Koha::Edifact and JSON download to
edimsg.pl

This patch implements a JSON representation of EDIFACT interchanges for
enhanced
programmatic access and debugging capabilities.

Backend Changes:
- Add to_json() method to Koha::Edifact module
- Structured JSON output with header, messages array, and trailer
- Segment parsing with raw data, elements arrays, and line_id tracking
- Line item grouping using LIN segment identifiers

Frontend Changes:
- Add JSON download button to edimsg.pl page
- Support for ?format=json parameter and Accept: application/json header
- Proper HTTP content-type handling for JSON responses
- Error handling for missing messages in JSON format

JSON Structure:
{
  "header": "UNB+UNOC:3+...",
  "messages": [
    {
      "header": "UNH+1+QUOTES:D:93A:UN:EAN008'",
      "segments": [
        {
          "tag": "LIN",
          "raw": "LIN+1+1+9780552150040:EN'",
          "elements": ["1", "1", "9780552150040:EN"],
          "line_id": "1"
        }
      ],
      "trailer": "UNT+25+1'"
    }
  ],
  "trailer": "UNZ+1+1'"
}

Test plan:
1. Apply this patch
2. Ensure you have EDIFACT messages in your system
3. Go to Acquisitions > EDIFACT messages
4. Click "View message" for any message
5. Click the new "JSON" button
6. Verify JSON downloads with proper structure
7. Verify direct URL access with ?format=json parameter works
8. Test with Accept: application/json header

Signed-off-by: Hannah Dunne-Howrie <[email protected]>

Signed-off-by: Kyle M Hall <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to