mahmoud / glom

☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
https://glom.readthedocs.io
Other
1.89k stars 61 forks source link

PathAccessError for value key with dot #230

Closed samir86TIIR closed 2 years ago

samir86TIIR commented 2 years ago

Hello,

It's not possible to use dot [.] on a value key with glom, For exemple:

target = { 'galaxy': { 'solar.system': { 'planet' : 'jupiter' } } } spec = 'galaxy.solar.system.planet' glom(target, spec)

We have this error, because the value 'solar.system' isn't recognize :

issue_glom

Any help will be greatly appreciated because it's very painful to modify a JSON file with a lot dotted keys.

mahmoud commented 2 years ago

Hey there Samir! Check out the Path spec type: https://glom.readthedocs.io/en/latest/api.html#glom.Path

samir86TIIR commented 2 years ago

Hi Mahmoud, It's working great, thank you for your reactivity, I'm a beginner glom user, and I will read more deeply glom functions :)