plz use Devel::Peek to find out if it's properly encoded and show us the result here

I've not come across Devel::Peek before, let alone used it - so please bear with me if this is not right...

#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use Site::Utils; use JSON; use Devel::Peek; print "Content-type: text/plain\n\n"; open my $fh, '<', '../data/publicextract.charity.json' or die "Unable +to read Charity JSON File"; my $data = <$fh>; print "$data\n\n"; open STDERR, ">", 'output.txt' or die $!; print STDERR "Before\n"; Dump ($data); $data =~ s/^\x{feff}//; # Strip off BOM print STDERR "\n\nAfter\n"; Dump ($data); exit;

This gives this output...

Before SV = PV(0x1569cf0) at 0x15877a0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x1c56920 "\357\273\277[{\"date_of_extract\":\"2023-01-16T00:00 +:00\",\"organisation_number\":1,\"registered_charity_number\":200027, +\"linked_charity_number\":1,\"charity_name\":\"POTTERNE MISSION ROOM +AND TRUST\",\"charity_type\":null,\"charity_registration_status\":\"R +emoved\",\"date_of_registration\":\"1962-05-17T00:00:00\",\"date_of_r +emoval\":\"2014-04-16T00:00:00\",\"charity_reporting_status\":null,\" +latest_acc_fin_period_start_date\":null,\"latest_acc_fin_period_end_d +ate\":null,\"latest_income\":null,\"latest_expenditure\":null,\"chari +ty_contact_address1\":null,\"charity_contact_address2\":null,\"charit +y_contact_address3\":null,\"charity_contact_address4\":null,\"charity +_contact_address5\":null,\"charity_contact_postcode\":null,\"charity_ +contact_phone\":null,\"charity_contact_email\":null,\"charity_contact +_web\":null,\"charity_company_registration_number\":null,\"charity_in +solvent\":false,\"charity_in_administration\":false,\"charity_previou +sly_excepted\":null,\"charity_is_cdf_or_cif\":null,\"charity_is_cio\" +:null,\"cio_is_dissolved\":null,\"date_cio_dissolution_notice\":null, +\"charity_activities\":null,\"charity_gift_aid\":null,\"charity_has_l +and\":null}\r\n"\0 CUR = 1082 LEN = 1122 After SV = PV(0x1569cf0) at 0x15877a0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x1c56920 "\357\273\277[{\"date_of_extract\":\"2023-01-16T00:00 +:00\",\"organisation_number\":1,\"registered_charity_number\":200027, +\"linked_charity_number\":1,\"charity_name\":\"POTTERNE MISSION ROOM +AND TRUST\",\"charity_type\":null,\"charity_registration_status\":\"R +emoved\",\"date_of_registration\":\"1962-05-17T00:00:00\",\"date_of_r +emoval\":\"2014-04-16T00:00:00\",\"charity_reporting_status\":null,\" +latest_acc_fin_period_start_date\":null,\"latest_acc_fin_period_end_d +ate\":null,\"latest_income\":null,\"latest_expenditure\":null,\"chari +ty_contact_address1\":null,\"charity_contact_address2\":null,\"charit +y_contact_address3\":null,\"charity_contact_address4\":null,\"charity +_contact_address5\":null,\"charity_contact_postcode\":null,\"charity_ +contact_phone\":null,\"charity_contact_email\":null,\"charity_contact +_web\":null,\"charity_company_registration_number\":null,\"charity_in +solvent\":false,\"charity_in_administration\":false,\"charity_previou +sly_excepted\":null,\"charity_is_cdf_or_cif\":null,\"charity_is_cio\" +:null,\"cio_is_dissolved\":null,\"date_cio_dissolution_notice\":null, +\"charity_activities\":null,\"charity_gift_aid\":null,\"charity_has_l +and\":null}\r\n"\0 CUR = 1082 LEN = 1122

Does that help?

UPDATE:

I've realised that because I am reading just the first line of the JSON file, it is malformed as it doesn't have the training ']' character. However, I have added $data .= ']'; to manually add it back on. This still doesn't solve the BOM issue at the end of the file but it might complicate testing...


In reply to Re^4: Rogue character(s) at start of JSON file (BOM; dumping references) by Bod
in thread Rogue character(s) at start of JSON file by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.