package JSON::Streaming::Writer;
use strict;
use warnings;
use IO::File;
use Carp;
use B;
use constant ROOT_STATE => {};
our $VERSION = '0.03';
sub for_stream {
my ($class, $fh) = @_;
my
);
my $state = $self->_push_state();
$state->{in_property} = 1;
$self->_print($self->_json_string($name), ":");
}
sub end_property {
my ($self) = @_;
Carp::croak("Can't end_prope
) unless $self->_can_start_simple_value;
$self->_make_separator();
$self->_print($self->_json_string($value));
$self->_state->{made_value} = 1;
}
sub add_number {
my ($self, $value)
package JSON::Streaming::Writer::TestUtil;
# Just some utility bits for the test scripts to use.
use strict;
use warnings;
use base qw(Exporter);
use JSON::Streaming::Writer;
use Symbol;
our @EXPO
= qw(test_jsonw test_jsonw_croak);
sub test_jsonw {
my ($test_name, $correct_output, $code) = @_;
my $fh = JSON::Streaming::Writer::TestUtil::FakeHandle->new();
my $jsonw = JSON::Streami
m($fh);
$code->($jsonw);
my $actual_output = $fh->result;
Test::More::is($correct_output, $actual_output, $test_name) if defined($correct_output);
}
sub test_jsonw_croak {
my ($tes