Thanks for every ones help. I got it working here's the working code. I had to remove from the original code the line with print <$cl>; I also had to alter each line to have a leading [ and a trailing ], it's now working. Working code:
#!/usr/bin/perl use strict; use IO::Socket::SSL; #qw(debug3); use JSON::SL; use Data::Dumper; print "JSON Stream parser test\r\n"; my $p = JSON::SL->new; #Look for everything past the first JSON pointer $p->set_jsonpointer(["/^"]); # simple client my $cl = IO::Socket::SSL->new( PeerAddr => 'example.com', PeerService => 'https', PeerPort => 443, Proto => 'tcp', Reuse => 1 ); die "no connection" unless $cl -> connected(); print $cl "GET /stream/report?token=IMNOTAREALTOKEN HTTP/1.0\r\n\r +\n"; #print <$cl>; #local $/ = \5; #read only 5 bytes at a time while (my $line = <$cl>) { chomp($line); #Remove new line characters $line = "[$line],\n"; # Add leading [ and trailing ], so i +t will parse correctly if ($line =~ m/{"\w{14}/) { print "Received:\n$line"; $p->feed($line); #parse what you can fetch anything that co +mpleted the parse and matches the JSON Pointer while (my $obj = $p->fetch) { print Dumper($obj); print "$obj->{Value}{flowStartSeconds}: $obj->{Value}{ +senderCallsign}\n"; } } } close $cl;

In reply to Re^3: Trying to decode JSON streaming from a website by ve6sar
in thread Trying to decode JSON streaming from a website by ve6sar

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.