package JSON::YAJL;
use strict;
use warnings;
use JSON::YAJL::Generator;
use JSON::YAJL::Parser;
our $VERSION = '0.10';
1;
=head1 NAME
JSON::YAJL - An interface to the YAJL JSON parsing and generat
1 SYNOPSIS
use JSON::YAJL;
# see JSON::YAJL::Generator or JSON::YAJL::Parser
=head1 DESCRIPTION
YAJL is Yet Another JSON Library. YAJL is a small event-driven (SAX-style) JSON
parser written in
ng JSON generator, by Lloyd
Hilaiel. This module is a Perl interface to that library.
To find out more about YAJL, please visit http://lloyd.github.com/yajl/
For the generation library, see L<JSON::
kage JSON::YAJL::Generator;
use strict;
use warnings;
our $VERSION = '0.10';
require XSLoader;
XSLoader::load( 'JSON::YAJL::Generator', $VERSION );
1;
=head1 NAME
JSON::YAJL::Generator - JSON gene
ration with YAJL
=head1 SYNOPSIS
use JSON::YAJL;
my $generator = JSON::YAJL::Generator->new();
# or to beautify (indent):
# my $generator = JSON::YAJL::Generator->new( 1, ' ' );
$genera
u to generate JSON with YAJL. This is quite a low-level
interface for generating JSON and it accumulates JSON in an internal buffer
until you fetch it.
If you create certain invalid JSON constructs t
package JSON::YAJL::Parser;
use strict;
use warnings;
our $VERSION = '0.10';
require XSLoader;
XSLoader::load( 'JSON::YAJL::Parser', $VERSION );
1;
=head1 NAME
JSON::YAJL::Parser - JSON parsing wi
th YAJL
=head1 SYNOPSIS
use JSON::YAJL;
my $text;
my $parser = JSON::YAJL::Parser->new(
0, 0,
[ sub { $text .= "null\n" },
sub { $text .= "bool: @_\n" },
unde
sub { $text .= "array_open\n" },
sub { $text .= "array_close\n" },
]
);
my $json
= '{"integer":123,"double":4,"number":3.141,"string":"a string","string2":"another string",
h
*
* Parses JSON data and returns the data in tree form.
*
* \author Florian Forster
* \date August 2010
*
* This interface makes quick parsing and extraction of
* smallish JSON docs trivial:
x02
/** A pointer to a node in the parse tree */
typedef struct yajl_val_s * yajl_val;
/**
* A JSON value representation capable of holding one of the seven
* types above. For "string", "number",
} array;
} u;
};
/**
* Parse a string.
*
* Parses an null-terminated string containing JSON data and returns a pointer
* to the top-level value (root of the parse tree).
*
* \param input
be reinitialized
* to zero.
*
* Finally, the output buffer is usually just a pointer into the jsonText,
* however in cases where the entity being lexed spans multiple chunks,
* the lexer will bu
performance.
*/
yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
size_t jsonTextLen, size_t * offset,
const unsigned char ** outBuf,
xer forward */
yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
size_t jsonTextLen, size_t offset);
typedef enum {
yajl_lex_e_ok = 0,
yajl_lex_
TH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* \file yajl_parse.h
* Interface to YAJL's JSON stream parsing facilities.
*/
#include <yajl_common.h>
#ifndef __YAJL_PARSE_H__
#define __YAJL
pedef struct yajl_handle_t * yajl_handle;
/** yajl is an event driven parser. this means as json elements are
* parsed, you are called back to do something with the data. The
* func
size_t numberLen);
/** strings are returned as pointers into the JSON text when,
* possible, as a result, they are _not_ null padded */
int (* yajl_st
stdlib.h>
#include <string.h>
#define NEED_newSVpvn_flags
#include "ppport.h"
typedef yajl_gen JSON__YAJL__Generator;
void croak_on_status(yajl_gen_status s) {
if (s == yajl_gen_status_ok) {
{
Perl_croak(aTHX_ "YAJL: Unknown status");
}
}
MODULE = JSON::YAJL::Generator PACKAGE = JSON::YAJL::Generator
JSON::YAJL::Generator new(package, unsigned int beautify = 0, const char *
RETVAL = g;
OUTPUT:
RETVAL
void integer(JSON::YAJL::Generator g, long int n)
CODE:
croak_on_status(yajl_gen_integer(g, n));
void double(JSON::YAJL::Generator g, double n)
CODE:
croak_
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* \file yajl_gen.h
* Interface to YAJL's JSON generation facilities.
*/
#include <yajl_common.h>
#ifndef __YAJL_GEN_H__
#define __YAJL_GEN_H
ed while in an error
* state */
yajl_gen_in_error_state,
/** A complete JSON document has been generated */
yajl_gen_generation_complete,
/**
* Set a function and context argument that should be used to
* output generated json. the function should conform to the
* yajl_print_t prototype while the context argument
ng.h>
#define NEED_newRV_noinc
#define NEED_sv_2pv_flags
#include "ppport.h"
typedef yajl_handle JSON__YAJL__Parser;
int DEBUG = 0;
void callback_call(SV* hashref, unsigned int index) {
HV* has
ose,
callback_array_open,
callback_array_close,
};
MODULE = JSON::YAJL::Parser PACKAGE = JSON::YAJL::Parser
JSON::YAJL::Parser new(package, unsigned int allowComments = 0, unsigned int
);
RETVAL = parser;
OUTPUT:
RETVAL
void parse(JSON::YAJL::Parser parser, SV* data)
CODE:
const char * jsonText;
unsigned int jsonTextLength;
yajl_status status;
unsigned char