Access property containing spaces
Closed this issue · 8 comments
Am I missing something or is there no way to access a property containing spaces? I tried two things:
> JSPath.apply("['hello world']", { 'hello world': 7 });
Error: Unexpected token "["
> JSPath.apply(".$name", { 'hello world': 7 }, {name: 'hello world'});
[]
I think it would be great to add the obj['prop']
syntax in addition to obj.prop
. To remain consistent with obj[0]
, it should probably also return an object instead of an array.
There is also no way to access a property containing a colon.
Yes, you are missing :)
You can use "
for that purpose. Your path can be written like this:
JSPath.apply('."hello world"', { 'hello world': 7 });
Thanks, that worked and should probably be mentioned in the README somewhere. Also, how would you go about getting a property that contains a "
, e.g. { 'hello "world"': 7 }
It seems right now you have no ability to select property with name containing "
Oh, thanks, fixed
I've added info about using of non-alphanumerical characters for properties in readme