PHP » GoLang |
login |
register |
about
|
GoLang JsonSerializable::jsonSerialize
request it (760)
GoLang replacement for PHP's JsonSerializable::jsonSerialize
[edit | history]
PHP JsonSerializable::jsonSerializePHP original manual for JsonSerializable::jsonSerialize [ show | php.net ]JsonSerializable::jsonSerialize(PHP 5 >= 5.4.0, PHP 7) JsonSerializable::jsonSerialize — Specify data which should be serialized to JSON DescriptionSerializes the object to a value that can be serialized natively by json_encode(). ParametersThis function has no parameters. Return ValuesReturns data which can be serialized by json_encode(), which is a value of any type other than a resource. Examples
Example #1 JsonSerializable::jsonSerialize() example returning an array
<?phpThe above example will output:
[
1,
2,
3
]
Example #2 JsonSerializable::jsonSerialize() example returning an associative array
<?phpThe above example will output:
{
"foo": "bar",
"quux": "baz"
}
Example #3 JsonSerializable::jsonSerialize() example returning an integer
<?phpThe above example will output: 1 Example #4 JsonSerializable::jsonSerialize() example returning a string
<?phpThe above example will output: "Hello!" |
more
Most requested
more
Last requests
|