https://github.com/zegl/dson-php
A DSON decoder / decoder in PHP
https://github.com/zegl/dson-php
Last synced: over 1 year ago
JSON representation
A DSON decoder / decoder in PHP
- Host: GitHub
- URL: https://github.com/zegl/dson-php
- Owner: zegl
- License: gpl-2.0
- Created: 2014-06-08T08:59:25.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-08T20:43:18.000Z (about 12 years ago)
- Last Synced: 2024-05-02T05:59:12.270Z (about 2 years ago)
- Language: PHP
- Homepage: http://dogeon.org
- Size: 165 KB
- Stars: 10
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
dson-php
======
DSON encoder/decoder for PHP

### What is dson-php?
dson-php is a simple DSON encoder
and decoder. It is a pure PHP-implementatin without any special dependencies.
### How to use?
#### DSON::encode($in)
```php
$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)
```php
$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 )
```php
$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"
}
}
```