defiant.js icon indicating copy to clipboard operation
defiant.js copied to clipboard

Add properties "nodeName", "parentNode" and contextual search

Open hbi99 opened this issue 11 years ago • 4 comments

Enabling features such as;

var found = JSON.search( data, '//item' );

found[0].nodename // item

found[0].parentNode // the parent object to the found item

found[0].search('./*[id=1]'); // searches only among children of found item

hbi99 avatar Jul 30 '14 22:07 hbi99

Hi,

I think this enhancement is not addressed yet, may I know when you guys are going to address this parent node, because lot of people are looking this kind of functionality.

Thanks & Regards, N.Murali Krishna.

muralinit avatar Mar 26 '15 06:03 muralinit

@muralinit I've solved this with objects/arrays but not with simple datatypes such as string, number, boolean, etc. So, if the found item is not simple type, the "parentNode" property can be accessed. Since, I only have half the solution, I've chosen to wait with the implementation.

hbi99 avatar Mar 26 '15 06:03 hbi99

Well good I am using objects in my current project, so for the current situation I can use your temporary solution. One more idea is you can publish the solution and open a new issue for addressing the issue on Simple types. In my opinion most of the people will use Objects so at least there will be relief. So please give me your changes. If they are in the current check-in I will take it from there.

Thanks & Regards, N.Murali Krishna.

muralinit avatar Mar 26 '15 06:03 muralinit

Hello,

Can I have your solution for objects/arrays please.

Thanks & Regards, N.Murali Krishna.

muralinit avatar Mar 26 '15 13:03 muralinit