Skip to content

Feature request: allow custom object container class during decode #62

@yairlenga

Description

@yairlenga

While looking through the code, I noticed that _object() already appears to support constructing object containers other than plain hashes.

Would it make sense to expose this through the public API?

Use cases include:

  • preserving key order
  • integrating with modules such as Hash::Ordered or Tie::IxHash
  • using custom mapping classes

For example, an API could look something like:

Sample implementation:

my $json = JSON->new
    ->object_class('Hash::Ordered');

my $obj = $json->decode($text);

Unless I'm missing something, part of the implementation may already be present internally, but there does not appear to be a public option to select the object container class.

Would you be interested in such a feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions