Skip to content

Instantly share code, notes, and snippets.

@marczhermo
Created April 6, 2012 13:48
Show Gist options
  • Save marczhermo/2319931 to your computer and use it in GitHub Desktop.
Save marczhermo/2319931 to your computer and use it in GitHub Desktop.
PHP: json_encode/decode
<?php
$data = array('description' => "TEST: quick brown fox",
'public' => true,
'files' => array('gistfile.php' => array('content' => "the quick brown fox jumps over the lazy dog.")));
$data_string = json_encode($data);
echo '<pre>'.$data_string.'<p>';
var_dump(json_decode('{
"description": "the description for this gist",
"public": true,
"files": {
"file1.txt": {
"content": "String file contents"
}
}
}',TRUE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment