PHP code example of wpkenpachi / wpdecodejson

1. Go to this page and download the library: Download wpkenpachi/wpdecodejson library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wpkenpachi / wpdecodejson example snippets


'providers' => [
    ...
    Wpkenpachi\WpDecodeJson\WPDecodeJsonProvider::class,
    ...
]


use Wpkenpacho\WpDecodeJson\DecodeJson;

class UserController extends Controller {

    public function index(){
        // Array exemplo
        $user = [
            "id" => 1,
            "localizacao" => '{"latitude":123141, "longitude": 12341541233}'
        ];

        return DecodeJson::decodeAll( $user );
        /* Output
        [
            [id] => 1,
            [localizacao] => [
                [latitude] => 123141,
                [longitude] => 12341541233
            ]
        ]
        ou em Json
        {
            id: 1,
            localizacao: {
                latitude: 123141,
                longitude: 12341541233
            }
        }
        */
    }

}