示例#1
0
<?php
$json = <<<JSON
{ "widget": {  "debug": "on",
   "window": {
    "title": "Sample Konfabulator Widget",
  "name": "main_window",
      "width": 500,
"height": 500
 }
 }
}
JSON;

$beautifier = new Zym_Js_Beautifier();
echo $beautifier->parse($json);

/*
{
    "widget": {
        "debug": "on",
        "window": {
            "title": "Sample Konfabulator Widget",
            "name": "main_window",
            "width": 500,
            "height": 500
        }
    }
}
*/
示例#2
0
 public function testIndentFromSetIndent()
 {
     $beautifier = new Zym_Js_Beautifier();
     $beautifier->setIndent(' ');
     $js = $beautifier->parse('{ one_char() }');
     $this->assertEquals("{\n one_char()\n}", $js);
     $beautifier = new Zym_Js_Beautifier();
     $beautifier->setIndent('    ');
     $js = $beautifier->parse('{ one_char() }');
     $this->assertEquals("{\n    one_char()\n}", $js);
 }