Skip to content

Usingvars breaks my pyjq.first command with Assertion failed: (JVP_HAS_KIND(key, JV_KIND_STRING)) #85

@jonsnowseven

Description

@jonsnowseven

Hello.

I am having the following issue regarding the use of vars argument.

This does not work:

data = dict(
    parameters= [
        dict(name="PKG_TAG_NAME", value="trunk"),
        dict(name="GIT_COMMIT", value="master"),
        dict(name="TRIGGERED_JOB", value="trunk-buildall")
    ],
    id="2013-12-27_00-09-37",
    changeSet=dict(items=[], kind="git"),
)
import pyjq
print(pyjq.first('$parameters[] | {"param_name": .name, "param_type": .type}', vars=data))

# returns Assertion failed: (JVP_HAS_KIND(key, JV_KIND_STRING)), function jv_object_set, file jv.c, line 1771.

But this works:

data = dict(
    parameters= [
        dict(name="PKG_TAG_NAME", value="trunk"),
        dict(name="GIT_COMMIT", value="master"),
        dict(name="TRIGGERED_JOB", value="trunk-buildall")
    ],
    id="2013-12-27_00-09-37",
    changeSet=dict(items=[], kind="git"),
)
import pyjq
print(pyjq.first('.parameters as $parameters | $parameters[] | {"param_name": .name, "param_type": .type}', data))

# {'param_name': 'PKG_TAG_NAME', 'param_type': None}

Am I assuming something wrong regarding the use of vars?

I am using Python 3.11 and pyjq 2.6.0 in a Macbook M2.

Thank you in advance.

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