8000 Updating a json object fails if the value of a key is boolean · Issue #73 · h2non/jsonpath-ng · GitHub
[go: up one dir, main page]

Skip to content
Updating a json object fails if the value of a key is boolean #73
@Andrewnopoulos

Description

@Andrewnopoulos

Related to #47

Steps to reproduce:

from jsonpath_ng import parse
selector = '$.*.number'
data = {
    'foo': ['abc', 'def'],
    'bar': {'number': 123456},
    'boolean': True
}
val = '98765'
expr = parse(selector)
expr.update(data, val)

Expected

'number' field to be updated to '98765'.

Observed

  File "/home/andrew/test.py", line 12, in <module>
    expr.update(data, val)
  File "/home/andrew/jsonpath_ng/jsonpath.py", line 261, in update
    self.right.update(datum.value, val)
  File "/home/andrew/jsonpath_ng/jsonpath.py", line 526, in update
    if field in data:
TypeError: argument of type 'bool' is not iterable

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

      0