Beispiel #1
0
<?php

require_once '../DSON.php';
use zegl\dson\DSON;
$tests = array(array('such "foo" is "bar" wow', '{"foo":"bar"}'), array('such "foo" is so "bar" and "baz" also "fizzbuzz" many wow', '{"foo":["bar","baz","fizzbuzz"]}'), array('such "foo" is 42very3 wow', '{"foo":42000}'), array('such " \\"such " is "bar" wow', '{" \\"such ":"bar"}'), array('such
                        " such " is "very bar" wow
            ', '{" such ":"very bar"}'), array('such "foo" is empty wow', '{"foo":null}'), array('such "foo" is so no and yes many wow', '{"foo":[false,true]}'), array('such "foo" is so "yes" and "no" many wow', '{"foo":["yes","no"]}'), array('such "foo" is "bar". "doge" is "shibe" wow', '{"foo":"bar","doge":"shibe"}'), array('such "foo" is such "shiba" is "inu", "doge" is yes wow wow', '{"foo":{"shiba":"inu","doge":true}}'), array('such "foo" is such "shiba" is "inu". "doge" is such "good" is yes! "a" is empty ? "b" is no wow wow wow', '{"foo":{"shiba":"inu","doge":{"good":true,"a":null,"b":false}}}'), array('"test"', '"test"'));
foreach ($tests as $test) {
    $obj = json_decode($test[1], true);
    $doge = DSON::encode($obj);
    if (DSON::decode($doge, true) === $obj) {
        echo "OK!";
    } else {
        var_dump($test[0], $doge);
    }
    echo "\n";
}
Beispiel #2
0
<?php

if (extension_loaded('xhprof')) {
    include_once '/usr/share/php/xhprof_lib/utils/xhprof_lib.php';
    include_once '/usr/share/php/xhprof_lib/utils/xhprof_runs.php';
    xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
require_once '../DSON.php';
use zegl\dson\DSON;
$tests = array(array('poop' => json_decode('"\\ud83d\\udca9"')), 'Hej, jag är en text med fina krumilurer');
foreach ($tests as $v) {
    var_dump($v);
    $encode = DSON::encode($v);
    $decode = DSON::decode($encode, true);
    var_dump($decode);
}
if (extension_loaded('xhprof')) {
    $xhprof_data = xhprof_disable();
    $xhprof_runs = new XHProfRuns_Default('/storage/xhprof/');
    $a = $xhprof_runs->save_run($xhprof_data, 'dson');
    var_dump($a);
}
Beispiel #3
0
<?php

require_once '../DSON.php';
use zegl\dson\DSON;
$tests = array(array('such "foo" is "bar" wow', '{"foo":"bar"}'), array('such "foo" is so "bar" and "baz" also "fizzbuzz" many wow', '{"foo":["bar","baz","fizzbuzz"]}'), array('such "foo" is 42very3 wow', '{"foo":42000}'), array('such " \\"such " is "bar" wow', '{" \\"such ":"bar"}'), array('such
                        " such " is "very bar" wow
            ', '{" such ":"very bar"}'), array('such "foo" is empty wow', '{"foo":null}'), array('such "foo" is so no and yes many wow', '{"foo":[false,true]}'), array('such "foo" is so "yes" and "no" many wow', '{"foo":["yes","no"]}'), array('such "foo" is "bar". "doge" is "shibe" wow', '{"foo":"bar","doge":"shibe"}'), array('such "foo" is such "shiba" is "inu", "doge" is yes wow wow', '{"foo":{"shiba":"inu","doge":true}}'), array('such "foo" is such "shiba" is "inu". "doge" is such "good" is yes! "a" is empty ? "b" is no wow wow wow', '{"foo":{"shiba":"inu","doge":{"good":true,"a":null,"b":false}}}'), array('"test"', '"test"'));
foreach ($tests as $test) {
    $res = DSON::decode($test[0], true);
    if ($res === json_decode($test[1], true)) {
        echo "OK!";
    } else {
        var_dump($test);
        var_dump($res);
    }
    echo "\n";
}