Closed rkleemann closed 5 years ago
If you really need such information, you should use Data::Dumper, Data::Dump, Data::Printer, or whatever you like to dump the content of an object. If you still need it as a JSON text, put that dump into an array, and pass its reference to encode_json(). If you use the latest JSON modules, you can put the dump directly into encode_json(). No need for extra code.
The latest JSON backends also have allow_tags()
option, and filter_json_object
callback, if you need finer control.
An idea I had was to allow the stringification of objects in some form that comes out as a readable string, which could be reinterpreted back as the object.
Consider the following object:
After a
say $json->encode([$obj]);
with the right options enabled, it would produce something like:The code seems fairly straightforward, going into
object_to_json
: