peachpie icon indicating copy to clipboard operation
peachpie copied to clipboard

PHP serializer to serialize IDictionary and IList

Open jakubmisek opened this issue 3 years ago • 0 comments

IDictionary and IList are well-known CLR types that should be handled by PHP serialization (php, and json) in order to provide better interoperability with CLR languages.

<?php
$obj = new \System\Collections\Generic\Dictionary<int, string>(); // passed from C# code usually
echo serialize( $obj );

Currently, it serializes the dictionary as any other PHP-like object; which fails sooner or later (weird properties, weird fields, cannot deserialize properly).

Expected: serialize IDictionary and IList as a PHP array.

  • [ ] json_encode() for IList
  • [x] json_encode() for IDictionary
  • [ ] serialize() for IList
  • [ ] serialize() for IDictionary

jakubmisek avatar Jan 18 '22 09:01 jakubmisek