-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
json_encode()
can ouptut empty object, but yaml_emit()
cannot.
Please tell me how to output empty object like {}
.
tested with versions:
php 8.1.8 (Windows x86_64)
php_yaml-2.2.2-8.1-nts-vs16-x64.zip
<?php
$a = [
'int' => 123,
'string' => 'aaa',
'array' => [],
'object_ok' => ['a'=>123],
'object_ng1' => (object)[],
'object_ng2' => (object)['a'=>123],
];
echo json_encode($a, JSON_PRETTY_PRINT), "\n", yaml_emit($a);
output:
{
"int": 123,
"string": "aaa",
"array": [],
"object_ok": {
"a": 123
},
"object_ng1": {},
"object_ng2": {
"a": 123
}
}
---
int: 123
string: aaa
array: []
object_ok:
a: 123
object_ng1: !php/object "O:8:\"stdClass\":0:{}"
object_ng2: !php/object "O:8:\"stdClass\":1:{s:1:\"a\";i:123;}"
...