Skip to content

Camel killer box without data mangling #279

Open
@jacobtomlinson

Description

@jacobtomlinson

The camel killer box is a great feature. I work a lot with data structures from Kubernetes which uses camel case everywhere, and it's really nice to be able to access them via snake case attributes.

>>> from box import Box
>>> data = Box({"loadBalancer": "foo"}, camel_killer_box=True)
>>> data.load_balancer
'foo'

I need to be able to modify these data structures and then send them back to the Kubernetes API. Unfortunately because Box defaults to destructively updating the underlying dictionary to use snake case there is no way for me to get a data structure out that the Kubernetes API will understand.

>>> data.load_balancer = "bar"
>>> data.to_dict()
{'load_balancer': 'bar'}  # Kubernetes wants {'loadBalancer': 'bar'}

Would it be possible to add some way to round trip a dict through a Box without mangling it, and still get the benefits of accessing snake case attributes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions