Warning: Invalid argument supplied for foreach() in /home/jihswbiz/public_html/t6.gwilt.org/refDox.php on line 212
Docs-dumpJson

 

ReLoad

Keys


Functions

arraybrowsercolorcookiedatetimeDBdebugdeviceDSTequiverrorflagsfontformatgeo
holidayhtmlisjsonmathparsePHPprintsearchsortstringtabletexttracetype
VOTDweatherxml

Function  dumpJson   Lines 116-183 (67 lines) file  utilsJson.php   Last mod: Mon 2021-02-22 18:04:09

function dumpJson $json )
        {
#-k     json    print

        
$quot false
        
$out '$x='
        
$json stripslashes$json );
        
$L $j 0;
        
$y true;
        
$ar callingVars );
        
prt $json );

        
$par $bra $squ $ang 0;
        
        
frame $json );
        for (
$i=0$i<strlen($json); $i++) 
                { 
                if (!
$quot
                        { 
                        if (
$json[$i] == '{')           { $out .= ' array(';    $v .= ' array('$L++; $bra++;
                        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L$j++; $k $v '';
                                                        
$y true; }
                        else if (
$json[$i] == '[')      { $out .= ' array(';    $v .= ' array('$L++; $squ++; 
                        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L$j++; $k $v '';
                                                        
$y true; }
                        else if (
$json[$i] == '}')      { 
                        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L$j++; $k $v '';
                                                        
$out .= ')';            $v .= ')';       $L--; $bra--; 
                                                        }
                        else if (
$json[$i] == ']')      { 
                        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L$j++; $k $v '';
                                                        
$out .= ')';            $v .= ')';       $L--; $squ--; 
                                                        }
                        else if (
$json[$i] == ':')      { $out .= $k '=>'$y false; }
                        else                            { if (
$y$k .= $json[$i]; else $v .= $json[$i]; }
                        if (
$json[$i] == ',')           { $out .= $v
                        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L$j++; $k $v '';
                                                        
$y true; }
                        if (
$json[$i] == '"')           $quot true;
                        if (
$json[$i] == '<')           $ang++;
                        if (
$json[$i] == '>')           $ang--;
                        if (
$json[$i] == '(')           $par++;
                        if (
$json[$i] == ')')           $par--;
                        } 
                else 
                        {
                        if (
$json[$i] == '"')
                                {
                                if (
$json[$i+1] == ':')         $quot false;
                                elseif (
$json[$i+1] == ',')     $quot false;
                                elseif (
$json[$i+1] == '}')     $quot false;
                                if (
$quot)      { if ($y$k .= "'"; else $v .= "'"; }                  # still in quot mode; swap the quote
                                
else            { if ($y$k .= $json[$i]; else $v .= $json[$i]; }      # coming out of quot mode; leave quote alone
                                
}
                        else
                                { if (
$y$k .= $json[$i]; else $v .= $json[$i]; }                      # it's a char inside the quotes
                        
}
                } 

        
$t[$j]['key'] = $k$t[$j]['val'] = $v$t[$j]['lvl'] = $L;
        
prt '<hr>Following are balanced if 0:');
        
prt '   parens: ' $par);
        
prt '   braces: ' $bra);
        
prt ' brackets: ' $squ);
        
prt '   angles: ' $ang);
        
build2DTable $t );
        }

?>