Example #1
0
 public function testParseExampleJson5()
 {
     $json5 = file_get_contents(JSON5_FILE_DIR . '/example.json5');
     $parser = new Parser($json5);
     $json = $parser->parse();
     $this->assertInstanceOf(stdClass::class, $json);
     $this->assertEquals('bar', $json->foo);
     $this->assertTrue($json->while);
     $this->assertEquals(INF, $json->to);
 }
Example #2
0
 /**
  * Decode JSON5 string.
  *
  * @param string $json5
  * @param bool   $assoc
  *
  * @return mixed
  */
 public static function decode($json5, $assoc = false)
 {
     $parser = new Parser($json5);
     return $parser->parse($assoc);
 }