Skip to content

incorrect output when using filters at leaf #15

@bytespireio

Description

@bytespireio

hi

For the json path = $['tool']['books'][*]['properties'][*][? (@['name'] == 'moq') ]['value']

the output based on the json below should be ["x","q"]

but i get []

I get the correct output when using

i tried alternative json path json_path='$.tool.books.[*].properties.[*].[?(@.name=="moq")]'

i get weird printed errors = [2022-11-02 15:43:23]-ERROR-[jsonpath] string indices must be integers

sample json is as follows:

{
	"tool": {
		"jsonpath": {
			"creator": {
				"name": "Jayway Inc.",
				"location": [
					"Malmo",
					"San Francisco",
					"Helsingborg"
				]
			}
		},
		"books": [{
				"title": "Beginning JSON",
				"price": 49.99,
				"properties": [{
					"name": "moq",
					"value": "x"
				}, {
					"name": "url",
					"value": "1"
				}]
			},
			{
				"price": 1.99,
				"properties": [{
					"name": "url",
					"value": "3"
				}]
			}, {
				"title": "JSON at Work",
				"price": 29.99,
				"properties": [{
					"name": "moq",
					"value": "q"
				}, {
					"name": "url",
					"value": "2"
				}]
			}
		]

	}
}

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