On Wed, Sep 8, 2021 at 5:38 PM Mike Schinkel <m...@newclarity.net> wrote:
> A couple more things; add a `JSON_OUTPUT_DYNAMIC_OBJECT` flag to output to > DynamicObject for `json_decode()`, add a 3rd parameter for flags to > var_export() for the same reason, a `'return_dynamic_object'` option for > `unserialize()`, and so on. > It would also be interesting to enter a user-defined class here to work as a reversed JsonSerializable. Could be a static factory method for all I care, and would omit the requirement of serialization libraries for "simple" things where you still want decent object typing. Could also work together with interfaces accepting properties, effectively making the result of json_decode an anonymous class that still adheres to an interface. In case of the custom 'deserialization' you can throw exceptions if the format is not correct. In the case of an anonymous class with an interface it could throw an exception if the structure doesn't match (possibly controlled by flags?).