kage JSON::SL::Boolean;
use overload
"0+" => sub { ${$_[0]} },
"++" => sub { $_[0] = ${$_[0]} + 1 },
"--" => sub { $_[0] = ${$_[0]} - 1 },
fallback => 1;
1;
package JSON::SL
use warnings;
use strict;
our $VERSION;
use base qw(Exporter);
our @EXPORT_OK = qw(decode_json unescape_json_string);
BEGIN {
$VERSION = '1.0.7';
require XSLoader;
XSLoader::load(__PACKA
s {
my ($self,$c) = @_;
if (!defined $c) {
require JSON::SL::EscapeTH;
my $ret = {};
tie(%$ret, 'JSON::SL::EscapeTH', $self);
return $ret;
} else {
package JSON::SL::EscapeTH;
use strict;
use warnings;
sub TIEHASH {
my ($cls,$o) = @_;
my $self = bless { pjsn => $o }, $cls;
return $self;
}
sub STORE {
my $self = $_[0];
$s
scape_settings($character, $boolean)
Inspects and modifies the preferences for unescaping JSON strings. JSON allows
several forms of escape sequences, either via the C<\uXXXX> form, or via a two-
cha
esultant string, thus:
\u0041 becomes A
For JSON structural tokens, the backslash is swallowed and the character following
it is left as-is. JSON I<requires> that these characters be escaped.
package JSON::SL::Tuba;
use strict;
use warnings;
use JSON::SL;
use base qw(Exporter);
our @EXPORT;
my (%ActionMap,%TypeMap);
my $_cg_typehash;
my $_cg_modehash;
BEGIN {
%ActionMap = (
'+' =
n'
);
%TypeMap = (
'{' => 'object',
'[' => 'list',
'c' => 'data',
'D' => 'json',
'#' => 'key',
'"' => 'string',
'^' => 'special',
'?' => 'boolean',
'=' => '
1;
__END__
=head1 NAME
JSON::SL::Tuba - High performance SAX-like interface for JSON
=head1 SYNOPSIS
Create a very naive JSON encoder using JSON::SL::Tuba
my $JSON ||= <<'EOJ';
{
"a
s' JSON::XS, particularly because it's fast,
* doesn't seem to rely on any external structures, and because
* numeric conversions aren't my ideas of fun.
*/
#ifndef JSONXS_INLINE_H_
#define JSONXS
_INLINE_H_
#include "perl-jsonsl.h"
#if __GNUC__ >= 3
# define expect(expr,value) __builtin_expect ((expr), (value))
# define INLINE static inline
#else
# define expect(ex
fine expect_true(expr) expect ((expr) != 0, 1)
#define jsonxs__atof_scan1(s,a,e,p,m) jsonxs__atof_scan1_THX(aTHX_ s,a,e,p,m)
INLINE void
jsonxs__atof_scan1_THX(pTHX_ const char *s,
#include "perl-jsonsl.h"
#include "jsonxs_inline.h"
/*
* JSON::SL, JSON::SL::Boolean
*/
#define MY_CXT_KEY "JSON::SL::_guts" XS_VERSION
typedef struct {
PLJSONSL* quick;
HV *stash_obj;
static int PLJSONSL_Escape_Table_dfl[0x80];
#define ESCTBL PLJSONSL_Escape_Table_dfl
#define PLJSONSL_CROAK_USAGE(m) \
die("JSON::SL: %s %s", GvNAME(CvGV(cv)), m)
#ifdef PLJSONSL_HAVE_HV_COMM
e delete_he(pjsn,hv,he) delete_he_THX(aTHX_ pjsn, hv, he)
static void
delete_he_THX(pTHX_ const PLJSONSL *dummy, HV* hv, HE* he)
{
char *kbuf;
STRLEN klen;
int is_utf8;
kbuf = HePV(he
#ifndef PERL_JSONSL_H_
#define PERL_JSONSL_H_
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <limits.h>
/**
* Default depth limit to
e PLJSONSL_MAX_DEFAULT 512
/**
* Key names for the information returned by
* JSONpointer results
*/
#define PLJSONSL_INFO_KEY_PATH "Path"
#define PLJSONSL_INFO_KEY_VALUE "Value"
#define PLJSONSL_I
EY_QUERY "JSONPointer"
/**
* Names of various perl globs
*/
#define PLJSONSL_CLASS_NAME "JSON::SL"
#define PLJSONSL_BOOLEAN_NAME "JSON::SL::Boolean"
#define PLJSONSL_PLACEHOLDER_NAME "JSON::SL::Pla
mon 'options' field:
my @options = (
["PLTUBA", "JSON::SL::Tuba", [qw(utf8 no_cache_mro cb_unified allow_unhandled)]],
["PLJSONSL", "JSON::SL", [qw(utf8 nopath noqstr max_size object_drip)]]
ters
EOC
foreach (@options) {
my ($ctype,$pkgname,$opts) = @$_;
print <<"EOC";
MODULE = JSON::SL PACKAGE = $pkgname PREFIX = $ctype\_
PROTOTYPES: DISABLED
EOC
my $ix_counter = 1;
GV* on_key;
GV* on_number;
GV* on_object;
GV* on_list;
GV* on_data;
GV* on_json;
GV* on_special;
GV* on_boolean;
GV* on_null;
GV* on_any;
GV* start_string;
GV* start_number;
GV* start_object;
GV* start_list;
GV* start_data;
GV* start_json;
GV* start_special;
GV* start_boolean;
GV* start_null;
GV* start_any;
GV* end
end_key;
GV* end_number;
GV* end_object;
GV* end_list;
GV* end_data;
GV* end_json;
GV* end_special;
GV* end_boolean;
GV* end_null;
GV* end_any;
} methgv;
#endif /
/**
* JSON Simple/Stacked/Stateful Lexer.
* - Does not buffer data
* - Maintains state
* - Callback oriented
* - Lightweight and fast. One source file and one header file
*
* Copyright (C) 2012
-2015 Mark Nunberg
* See included LICENSE file for license details.
*/
#ifndef JSONSL_H_
#define JSONSL_H_
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <
s */
#ifdef JSONSL_USE_WCHAR
typedef jsonsl_char_t wchar_t;
typedef jsonsl_uchar_t unsigned wchar_t;
#else
typedef char jsonsl_char_t;
typedef unsigned char jsonsl_uchar_t;
#endif /* JSONSL_USE_WCHAR
', '#'],
['number', '=' ],
['object', '{'],
['list', '[' ],
['data', 'c' ],
['json', 'D' ],
['special', '^' ],
['boolean', '?' ],
['null', '~' ],
#this is a pseudo-
util/accessors.pl' and is meant to generate easy boolean
# getters and setters
MODULE = JSON::SL PACKAGE = JSON::SL::Tuba PREFIX = PLTUBA_
PROTOTYPES: DISABLED
#define PLTUBA_OPTION_IX_utf8 1
#defi
LE = JSON::SL PACKAGE = JSON::SL PREFIX = PLJSONSL_
PROTOTYPES: DISABLED
#define PLJSONSL_OPTION_IX_utf8 1
#define PLJSONSL_OPTION_IX_nopath 2
#define PLJSONSL_OPTION_IX_noqstr 3
#define PLJSONSL_OP
max_size 4
#define PLJSONSL_OPTION_IX_object_drip 5
int
PLJSONSL__options(PLJSONSL* obj, ...)
ALIAS:
utf8 = PLJSONSL_OPTION_IX_utf8
nopath = PLJSONSL_OPTION_IX_nopath