-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Some objects overload numification or stringification, but don't have a TO_JSON method. It would be nice for those objects to be encoded without having to monkey patch a TO_JSON method for them. The one that pops to mind is URI, but there are others.
The following code would go somewhere in object_to_json, and should work for this.
if ( $use_overload && overload::Overloaded($obj) ) {
if ( my $overload = overload::Method( $obj, '0+' )
|| overload::Method( $obj, '""' ) )
{
return $self->value_to_json( $obj->$overload() );
}
}
There would also be a sub to turn on/off the feature, and require overload; when it is enabled.
Metadata
Metadata
Assignees
Labels
No labels