1. Go to this page and download the library: Download laktak/hjson 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/ */
laktak / hjson example snippets
$parser = new HJSONParser();
$stringifier = new HJSONStringifier();
$text = "{
# specify rate in requests/second (because comments are helpful!)
rate: 1000
// prefer c-style comments?
/* feeling old fashioned? */
# did you notice that rate doesn't need quotes?
hey: look ma, no quotes for strings either!
# best of all
notice: []
anything: ?
# yes, commas are optional!
array: [
// hello
0
1
2
]
}";
// Parse, keep whitespace and comments
$data = $parser->parseWsc($text);
// Modify like you normally would
$data->rate = 500;
// You can also edit comments by accessing __WSC__
$wsc1 = &$data->__WSC__; // for objects
$wsc2 = &$data->array['__WSC__']; // for arrays
// __WSC__ for objects contains { c: {}, o: [] }
// - c with the actual comment and, firts comment is key ' '
// - o (array) with the order of the members
$emptyKey = " ";
$wsc1->c->$emptyKey = "\n # This is the first comment";
$wsc1->c->rate = "\n # This is the comment after rate";
// Sort comments order just because we can
sort($wsc1->o);
// Edit array comments
$wsc2[0] .= ' world';
// convert back to Hjson
$text2 = $stringifier->stringifyWsc($data);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.