You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When it come to array how can I do same queries? I have tried:
constarray={categories: [[['apple','apple.jpg'],['pear','pear.jpg']],[['keyboard','keyboard.jpg'],['mouse','mouse.jpg']]]}it('should allows query array by value at index (.[0]) and return value at another index (.[1])',()=>{constr=JSPath.apply('.categories..{.[0] === "apple"}.[1]',array)expect(r).toBe(['apple.jpg'])// fails...})it('should allows query array by index and return parent object',()=>{constr=JSPath.apply('.categories{..[0] === "apple"}[0]',array)expect(r).toEqual([['apple','apple.jpg'],['pear','pear.jpg']])// coincidentally works... })})
How can I do the same query when inner object become array.
Would it be possible to make .[index] and {.[index] === xxx} works like .prop and {.prop === xxx} for object?
The text was updated successfully, but these errors were encountered:
Arrays have special meaning in jspath, they are treated as nodesets.
So when .categories.. is applied, result will be ['apple', 'apple.jpg', 'pear', 'pear.jpg', 'keyboard','keyboard.jpg', 'mouse', 'mouse.jpg']. There is no way (in the current implementation) to determine what [0] should be.
For object we have:
When it come to array how can I do same queries? I have tried:
.[index]
and{.[index] === xxx}
works like.prop
and{.prop === xxx}
for object?The text was updated successfully, but these errors were encountered: