stefankoegl / python-json-pointer

Resolve JSON Pointers in Python
https://python-json-pointer.readthedocs.org/
Other
140 stars 43 forks source link

str/repr, join, and setting - for arrays #49

Closed benkehoe closed 2 years ago

benkehoe commented 2 years ago

I batched these together but can split them out/discard as desired.

__str__ and __repr__ methods

Pretty straightforward, some hoops to jump through for Python 2 support, as __str__ should return a str, not unicode (#48 is relevant).

Join

Add a join() method for combining two pointers. Works with strings and parts as well (can be more restrictive on types if you want). Also supports the / magic method (__truediv__ in Python 3, __div__ in Python 2), like pathlib.

Setting - for arrays

A pointer like /foo/- represents the element past the end of an array. Calling set() with one of these pointers should append to the array.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling d811454192adb18fc3a9aa333fc27e4e48ddd723 on benkehoe:master into 896102d605605ec0f48e26bafb54fb591be66ede on stefankoegl:master.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling d811454192adb18fc3a9aa333fc27e4e48ddd723 on benkehoe:master into 896102d605605ec0f48e26bafb54fb591be66ede on stefankoegl:master.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling d811454192adb18fc3a9aa333fc27e4e48ddd723 on benkehoe:master into 896102d605605ec0f48e26bafb54fb591be66ede on stefankoegl:master.

stefankoegl commented 2 years ago

Great, thanks a lot!