15
In PHP there is a language proper data serialization feature. I mean: I’m not talking about using JSON
or XML
, but I speak of a serialization in a format that is proper to the language.
For example, if I want to serialize a array
or a objeto
, I can do that easily.
serialize(['a' => 1, 'b' => 2])
The result will be:
'a:2:{s:1:"a";i:1;s:1:"b";i:2;}'
If I want to deserialize this data, I can invoke the function unserialize
to convert this data to a valid PHP value.
Behold:
unserialize('a:2:{s:1:"a";i:1;s:1:"b";i:2;}')
The result will be:
[
"a" => 1,
"b" => 2,
]
In conclusion, this is a specific format, where the language itself will understand which data needs to be converted.
In C# is there something similar? Is there some form of native data serialization of the language?
Note: Just to reinforce: I’m not talking about JSON or XML, but in a native way, as demonstrated in the PHP example.
Note that serialization can be any format, a language can adopt Json by default for example: https://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats
– Guilherme Nascimento