PHP code example of alglyzin / json

1. Go to this page and download the library: Download alglyzin/json 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/ */

    

alglyzin / json example snippets




    use alglyzin\Json\Json;

    $json = '  {
        "a": 0.00000001e23,
        "b": 0.00000001,
        "c": 10000000000.0e+45,
        "d": 0.00000001e-3,
        "e": 10.0E4,
        "f": 1000000000.0E-34,
        "g": 0.000000000000001,
        "h": 100000
    }';

    $json = Json::float_safe($json);

    echo $json;

    // echo $json:
    //    {
    //        "a": "0.00000001e23",
    //        "b": "0.00000001",
    //        "c": "10000000000.0e+45",
    //        "d": "0.00000001e-3",
    //        "e": "10.0E4",
    //        "f": "1000000000.0E-34",
    //        "g": "0.000000000000001",
    //        "h": 100000
    //    }
preg_replace