Acme-IsItJSON

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.02 2016-10-13
* Add LICENCE section to Pod

0.01 2015-11-03
* Is it JSON?

MANIFEST  view on Meta::CPAN

Changes
lib/Acme/IsItJSON.pm
lib/Acme/IsItJSON.pod
Makefile.PL
MANIFEST			This list of files
MANIFEST.SKIP
README
t/acme-isitjson.t
META.yml                                 Module YAML meta-data (added by MakeMaker)
META.json                                Module JSON meta-data (added by MakeMaker)

MANIFEST.SKIP  view on Meta::CPAN

build\.pl
blib/.*
.gitignore
.git/.*
Makefile$
pm_to_blib
MYMETA..*
.*\.bak
^Acme-IsItJSON-[0-9\.]+/$
^Acme-IsItJSON-[0-9\.]+\.tar\.gz$
^xt/.*\.t$
^lib/Acme/IsItJSON\.pod\.tmpl$

META.json  view on Meta::CPAN

{
   "abstract" : "Is my variable JSON or a Perl data structure?",
   "author" : [
      "Ben Bullock <bkb@cpan.org>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
      "version" : "2"
   },
   "name" : "Acme-IsItJSON",
   "no_index" : {
      "directory" : [
         "t",
         "inc"
      ]
   },
   "prereqs" : {
      "build" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "JSON::Create" : "0.22",
            "JSON::Parse" : "0.42",
            "perl" : "5.006001"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/benkasminbullock/acme-isitjson/issues"
      },
      "repository" : {
         "type" : "git",
         "url" : "git://github.com/benkasminbullock/acme-isitjson.git",
         "web" : "https://github.com/benkasminbullock/acme-isitjson"
      }
   },
   "version" : "0.02",
   "x_serialization_backend" : "JSON::PP version 2.27300"
}

META.yml  view on Meta::CPAN

---
abstract: 'Is my variable JSON or a Perl data structure?'
author:
  - 'Ben Bullock <bkb@cpan.org>'
build_requires:
  ExtUtils::MakeMaker: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Acme-IsItJSON
no_index:
  directory:
    - t
    - inc
requires:
  JSON::Create: '0.22'
  JSON::Parse: '0.42'
  perl: '5.006001'
resources:
  bugtracker: https://github.com/benkasminbullock/acme-isitjson/issues
  repository: git://github.com/benkasminbullock/acme-isitjson.git
version: '0.02'
x_serialization_backend: 'CPAN::Meta::YAML version 0.016'

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;
use ExtUtils::MakeMaker;

my $pm = 'lib/Acme/IsItJSON.pm';
my $pod = 'lib/Acme/IsItJSON.pod';
my $github = 'github.com/benkasminbullock/acme-isitjson';
my $repo = "https://$github";

WriteMakefile (
    NAME => 'Acme::IsItJSON',
    VERSION_FROM => $pm,
    ABSTRACT_FROM => $pod,
    AUTHOR => 'Ben Bullock <bkb@cpan.org>',
    LICENSE => 'perl',
    PREREQ_PM => {
	'JSON::Parse' => '0.42',
	'JSON::Create' => '0.22',
    },
    META_MERGE => {
	'meta-spec' => {
	    version => 2,
	},
        resources => {
            repository => {
		type => 'git',
		url => "git://$github.git",
		web => $repo,

README  view on Meta::CPAN

  /_/   \_\___|_| |_| |_|\___| (_|_)
                                    
   ___     ___ _      _ ____   ___  _   _ 
  |_ _|___|_ _| |_   | / ___| / _ \| \ | |
   | |/ __|| || __|  | \___ \| | | |  \| |
   | |\__ \| || || |_| |___) | |_| | |\  |
  |___|___/___|\__\___/|____/ \___/|_| \_|
                                          


This is the README for Acme::IsItJSON version 0.02.

Acme::IsItJSON is a "module" for the Perl computer programming language, a
library of computer code to install on a computer.  This document contains
four sections:

1. About - what the module does

2. Documentation - how to learn more about the module

3. Installation - how to install this module on a computer

4. Help - what to do if you get stuck

-----------------------------------------------------------------------------

1. ABOUT

Acme::IsItJSON - Is my variable JSON or a Perl data structure?

Not sure if your variable is a Perl data structure or a JSON string?

This Perl module can help.

-----------------------------------------------------------------------------

2. DOCUMENTATION

You can read the documentation for the module online at the following
websites:

    * http://search.cpan.org/perldoc?Acme::IsItJSON
    * http://metacpan.org/release/Acme-IsItJSON

(These links go to the latest version of the module.)

After installing the module, you can read the documentation on your
computer using

    perldoc Acme::IsItJSON

-----------------------------------------------------------------------------

3. INSTALLATION

This module requires Perl version 5.6.1 or later.

To install the module from CPAN, use

    cpan Acme::IsItJSON

If you have the App::cpanminus installer, you may prefer

    cpanm Acme::IsItJSON

To install the module from the source file, Acme-IsItJSON-0.02.tar.gz,
follow this sequence of commands:

    tar xfz Acme-IsItJSON-0.02.tar.gz
    cd Acme-IsItJSON-0.02
    perl Makefile.PL
    make
    make install

If you want to test the module before installing it, use "make test" after
"make" and before "make install".

-----------------------------------------------------------------------------

4. HELP

To get help with the module, you can email the author, Ben Bullock, at
<bkb@cpan.org>. If you think there is a problem in the module, you can
report a bug at 

<https://github.com/benkasminbullock/acme-isitjson/issues>,

or if you want to alter the source code of Acme::IsItJSON, try the public
repository on github at 

<https://github.com/benkasminbullock/acme-isitjson>. 

-----------------------------------------------------------------------------

This README was written on Thu Oct 13 13:36:08 2016.

-----------------------------------------------------------------------------

lib/Acme/IsItJSON.pm  view on Meta::CPAN

package Acme::IsItJSON;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw/is_it_json/;
%EXPORT_TAGS = (
    all => \@EXPORT_OK,
);
use warnings;
use strict;
use Carp;
use JSON::Parse qw/parse_json valid_json/;
use JSON::Create 'create_json';
our $VERSION = '0.02';

my @responses = (
    "That seems to be {X}.",
    "That might be {X}.",
    "I'm not sure whether that is {X}.",
    "It could be {X}.",
    "OK, it's definitely {X}. Maybe.",
);

lib/Acme/IsItJSON.pm  view on Meta::CPAN

    if (rand (2) > 1) {
	$response = create_json ($response);
    }
    print "$response\n";
}

sub is_it_json
{
    my ($input) = @_;
    if (valid_json ($input)) {
	babble ('JSON');
    }
    else {
	babble ('a Perl data structure');
    }
}

1;

lib/Acme/IsItJSON.pod  view on Meta::CPAN

=encoding UTF-8

=head1 NAME

Acme::IsItJSON - Is my variable JSON or a Perl data structure?

=head1 SYNOPSIS

    use Acme::IsItJSON 'is_it_json';
    my $json = '{"zilog":"z80"}';
    is_it_json ($json);
    my $perl = {zilog => 'z80'};
    is_it_json ($json);

=head1 DESCRIPTION

Not sure if your variable is a Perl data structure or a JSON string?

This Perl module can help.

=head1 FUNCTIONS

=head2 is_it_json

Given a variable containing something which you are not sure about,
and it may or may not be JSON or a Perl data structure, feed it to
this routine. This module uses support vector machines running on an
OCAML cluster backed up by a Node pipeline in an S3 cloud to
distinguish JSON from Perl data structures.

=head1 SEE ALSO

L<JSON::Meth> - does something similar to this module

=head1 AUTHOR

Ben Bullock <bkb@cpan.org>

=head1 LICENCE

You can use Acme::IsItJSON under the same terms as Perl
itself. Alternatively, you can throw it in the fruit cellar where it
belongs.

t/acme-isitjson.t  view on Meta::CPAN

# This is a test for module Acme::IsItJSON.

use warnings;
use strict;
use Test::More;
use Acme::IsItJSON 'is_it_json';

my $perl = { this => 'is', Not => 'json' };
my $json = '{"but":"this","IS":"json"}';

open my $out, ">", \my $output or die $!;
select $out;
is_it_json ($perl);
like ($output, qr/a perl data structure/i);
note ($output);

$output = '';

is_it_json ($json);
like ($output, qr/JSON/);
note ($output);
done_testing ();

# Local variables:
# mode: perl
# End:



( run in 1.729 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )