json() public method

JSON parser, helper function.
public json ( $payload ) : array
$payload
return array
Example #1
0
 /** @test */
 public function throws_an_exception_when_parsed_json_bad_data()
 {
     $parser = new Parser();
     $this->setExpectedException('Exception', 'Failed To Parse JSON');
     $parser->json('as|df>ASFBw924hg2=');
 }
 public function geo($id)
 {
     $region = Region::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($region['geo']));
 }
 public function geo($id)
 {
     $village = Village::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($village['geo']));
 }
 public function geo($id)
 {
     $county = County::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($county['geo']));
 }
Example #5
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>JSON Example</h1>";
$parsed = $parser->json('
    {
        "message": {
            "to": "Jack Smith",
            "from": "Jane Doe",
            "subject": "Hello World",
            "body": "Hello, whats going on..."
        }
    }');
echo "<pre>";
print_r($parsed);
echo "</pre>";
 public function geo($id)
 {
     $municipality = Municipality::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($municipality['geo']));
 }