Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON.search is failing when a string contains double quotes... #7

Closed
updiversity opened this issue Apr 5, 2014 · 3 comments
Closed

Comments

@updiversity
Copy link

Hi,

I tried to use this library to perform some extraction of nodes in my JSON array. However, the function JSON.search is crashing when it is trying to evaluate this line

JSON.search(x,"//*[title = 'this is "NOT" me']);

I tried using escape, double escape but it continue to fail. Is it a bug or a problem with my expression ?

Thks

@hbi99
Copy link
Owner

hbi99 commented Apr 5, 2014

Hello,
No bug...your XPath expression needed a little adjustment. Here is how it should be;

"//*[title='this is "NOT" me']"

Check out this fiddle (with simple & fast JSON structure - it just do the job for this example):
http://jsfiddle.net/YLBFa/

Cheers

@hbi99 hbi99 closed this as completed Apr 5, 2014
@updiversity
Copy link
Author

Thanks for the reply. I found the solution right after my post. Sorry for the noise.

@hbi99
Copy link
Owner

hbi99 commented Apr 6, 2014

No worries :)
Using the XPath Evaluator tool I've wrote, will help finding the right XPath expression:
http://defiantjs.com/#xpath_evaluator

You can modify the search structure and it indicates hits live when writing your expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants