Skip to content

The extract_data_from_json does not work when the jmespath is an integer or float #159

@smk4664

Description

@smk4664

Environment

  • Python version: 3.12
  • jdiff version: 1.0.2

Expected Behavior

I can use diff's extract_data_from_json to extract integer's or floats

Observed Behavior

TypeError: 'float' object is not iterable.

Steps to Reproduce

Provide the jmespath get_facts.uptime when parsing the data from the Napalm get_facts command.

The issue is that the return from jmespath.search("get_facts.uptime", data) is 5343600.0, which is not a list. This bug likely has not come up since lists, dictionaries and strings are all scalers, so iterating on them will succeed.

OR

a simpler version is:

extract_data_from_json({"x": 5}, "x") raises TypeError: 'int' object is not iterable

if any(isinstance(i, list) for i in values):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions