Imported Upstream version 0.58
This commit is contained in:
17
examples/json_bench.pl
Normal file
17
examples/json_bench.pl
Normal file
@@ -0,0 +1,17 @@
|
||||
BEGIN { $ENV{PERL_JSON_BACKEND}=0; }
|
||||
|
||||
use File::Slurp 'read_file';
|
||||
use JSON;
|
||||
use JSON::Tiny;
|
||||
use Benchmark 'cmpthese';
|
||||
|
||||
my @json = split /-{4}/, read_file('sample.json');
|
||||
|
||||
sub json_pp {
|
||||
my $j = JSON->new->relaxed;
|
||||
[ map { $j->decode($_) } @json ];
|
||||
}
|
||||
|
||||
sub json_tiny { [ map { JSON::Tiny::decode_json $_ } @json ]; }
|
||||
|
||||
cmpthese -15, { JSON_PP => \&json_pp, JSON_Tiny => \&json_tiny };
|
||||
10
examples/json_pp.pl
Normal file
10
examples/json_pp.pl
Normal file
@@ -0,0 +1,10 @@
|
||||
BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } # JSON::PP.
|
||||
|
||||
use JSON;
|
||||
|
||||
my @json
|
||||
= split /-{4}/, do { open my $fh, '<sample.json'; local $/ = undef; <$fh> };
|
||||
|
||||
sub json_pp { my $j = JSON->new; [ map { $j->decode($_) } @json ]; }
|
||||
|
||||
my $value = json_pp;
|
||||
9
examples/json_tiny.pl
Normal file
9
examples/json_tiny.pl
Normal file
@@ -0,0 +1,9 @@
|
||||
use JSON::Tiny 'j';
|
||||
|
||||
my @json
|
||||
= split /-{4}/, do { open my $fh, '<sample.json'; local $/ = undef; <$fh> };
|
||||
|
||||
sub json_tiny { [ map { j $_ } @json ]; }
|
||||
|
||||
my $value = json_tiny;
|
||||
|
||||
7
examples/sample.json
Normal file
7
examples/sample.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{"firstName":"John","lastName":"Smith","address":{"state":"NY","streetAddress":"21 2nd Street","city":"New York","postalCode":"10021"},"phoneNumber":[{"number":"212 555-1234","type":"home"},{"type":"fax","number":"646 555-4567"}],"age":25}
|
||||
----
|
||||
{"properties":{"price":{"type":"number","minimum":0,"required":true},"stock":{"type":"object","properties":{"retail":{"type":"number"},"warehouse":{"type":"number"}}},"tags":{"items":{"type":"string"},"type":"array"},"name":{"description":"Name of the product","type":"string","required":true},"id":{"required":true,"type":"number","description":"Product identifier"}},"name":"Product"}
|
||||
----
|
||||
{"price":123,"tags":["Bar","Eek"],"stock":{"warehouse":300,"retail":20},"id":1,"name":"Foo"}
|
||||
----
|
||||
{"web-app":{"taglib":{"taglib-uri":"cofax.tld","taglib-location":"\/WEB-INF\/tlds\/cofax.tld"},"servlet-mapping":{"fileServlet":"\/static\/*","cofaxAdmin":"\/admin\/*","cofaxTools":"\/tools\/*","cofaxEmail":"\/cofaxutil\/aemail\/*","cofaxCDS":"\/"},"servlet":[{"servlet-class":"org.cofax.cds.CDSServlet","init-param":{"dataStoreClass":"org.cofax.SqlDataStore","dataStoreUrl":"jdbc:microsoft:sqlserver:\/\/LOCALHOST:1433;DatabaseName=goon","redirectionClass":"org.cofax.SqlRedirection","dataStoreLogLevel":"debug","cachePagesTrack":200,"dataStoreInitConns":10,"configGlossary:poweredByIcon":"\/images\/cofax.gif","cachePackageTagsStore":200,"cachePackageTagsRefresh":60,"dataStoreConnUsageLimit":100,"cacheTemplatesTrack":100,"maxUrlLength":500,"dataStoreName":"cofax","searchEngineFileTemplate":"forSearchEngines.htm","searchEngineListTemplate":"forSearchEnginesList.htm","configGlossary:installationAt":"Philadelphia, PA","useJSP":false,"cachePagesRefresh":10,"templateProcessorClass":"org.cofax.WysiwygTemplate","cachePagesDirtyRead":10,"cacheTemplatesRefresh":15,"dataStoreLogFile":"\/usr\/local\/tomcat\/logs\/datastore.log","templateLoaderClass":"org.cofax.FilesTemplateLoader","jspFileTemplate":"articleTemplate.jsp","defaultFileTemplate":"articleTemplate.htm","searchEngineRobotsDb":"WEB-INF\/robots.db","templatePath":"templates","configGlossary:staticPath":"\/content\/static","dataStoreTestQuery":"SET NOCOUNT ON;select test='test';","dataStorePassword":"dataStoreTestQuery","cachePackageTagsTrack":200,"dataStoreUser":"sa","defaultListTemplate":"listTemplate.htm","templateOverridePath":"","dataStoreMaxConns":100,"dataStoreDriver":"com.microsoft.jdbc.sqlserver.SQLServerDriver","cachePagesStore":100,"configGlossary:adminEmail":"ksm@pobox.com","jspListTemplate":"listTemplate.jsp","configGlossary:poweredBy":"Cofax","cacheTemplatesStore":50,"useDataStore":true},"servlet-name":"cofaxCDS"},{"servlet-name":"cofaxEmail","init-param":{"mailHostOverride":"mail2","mailHost":"mail1"},"servlet-class":"org.cofax.cds.EmailServlet"},{"servlet-class":"org.cofax.cds.AdminServlet","servlet-name":"cofaxAdmin"},{"servlet-name":"fileServlet","servlet-class":"org.cofax.cds.FileServlet"},{"servlet-name":"cofaxTools","init-param":{"dataLogMaxSize":"","fileTransferFolder":"\/usr\/local\/tomcat\/webapps\/content\/fileTransferFolder","removePageCache":"\/content\/admin\/remove?cache=pages&id=","removeTemplateCache":"\/content\/admin\/remove?cache=templates&id=","log":1,"adminGroupID":4,"betaServer":true,"dataLogLocation":"\/usr\/local\/tomcat\/logs\/dataLog.log","lookInContext":1,"logMaxSize":"","templatePath":"toolstemplates\/","logLocation":"\/usr\/local\/tomcat\/logs\/CofaxTools.log","dataLog":1},"servlet-class":"org.cofax.cms.CofaxToolsServlet"}]}}
|
||||
Reference in New Issue
Block a user