zegl / dson-php
DSON encoder and decoder for PHP
Installs: 30
Dependents: 0
Suggesters: 1
Security: 0
Stars: 10
Watchers: 3
Forks: 0
pkg:composer/zegl/dson-php
This package is not auto-updated.
Last update: 2025-10-07 09:01:52 UTC
README
DSON encoder/decoder for PHP
What is dson-php?
dson-php is a simple DSON http://dogeon.org encoder and decoder. It is a pure PHP-implementatin without any special dependencies.
How to use?
DSON::encode($in)
$example = array( "many" => "wow", "such" => array("foo", "doge", "inu") ); echo DSON::encode($example);
such "many" is "wow" ! "such" is so "foo" and "doge" and "inu" many wow
DSON::decode($str, $assoc = false)
$res = DSON::decode('such "many" is "wow" ! "such" is so "foo" and "doge" and "inu" many wow');
object(stdClass)#1 (2) {
["many"]=>
string(3) "wow"
["such"]=>
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(4) "doge"
[2]=>
string(3) "inu"
}
}
Setting $assoc = true
will generate the output as an associative array instead, (compare to http://php.net/json_decode)
$res = DSON::decode('such "many" is "wow" ! "such" is so "foo" and "doge" and "inu" many wow', true);
array(2) {
["many"]=>
string(3) "wow"
["such"]=>
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(4) "doge"
[2]=>
string(3) "inu"
}
}