cdgriffith / cdgriffith/Box

Camel killer box without data mangling

Open
#279 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
2.8k
Forks
135
PR merge metrics
No merged PRs in 30d

Description

The [camel killer box](https://github.com/cdgriffith/Box/wiki/Types-of-Boxes#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.

```python
>>> 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.

```python
>>> 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.