Skip to content

Conversation

SergeyNikolaev
Copy link
Contributor

Trying to get a value of a key in hash form, and got an exception

Error in JSONPath near '.6ea500130ed280048b262ce6b3fe4ea0f97b75ad'

So the simple fix is to add a numbers to a string keys.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 098a0a6 on SergeyNikolaev:compoundKey into d08d1ef on Skyscanner:master.

@Galbar
Copy link
Owner

Galbar commented Oct 19, 2018

Hi! Thank you for the contribution!

In this case I suggest you use the bracket operator to access it. Like $.foo.bar["6ea500130ed280048b262ce6b3fe4ea0f97b75ad"]

The reason names starting with numbers is not supported is because they are not valid variable names in JS:

>> var 1oo = 2
SyntaxError: identifier starts immediately after numeric literal

Let me know if this helped you and/or if you still would like to discuss further supporting names like this 😃

@SergeyNikolaev
Copy link
Contributor Author

I was trying to access json value as $.foo.bar.6ea500130ed280048b262ce6b3fe4ea0f97b75ad.

@SergeyNikolaev
Copy link
Contributor Author

Hi! Thank you for the contribution!

In this case I suggest you use the bracket operator to access it. Like $.foo.bar["6ea500130ed280048b262ce6b3fe4ea0f97b75ad"]

The reason names starting with numbers is not supported is because they are not valid variable names in JS:

>> var 1oo = 2
SyntaxError: identifier starts immediately after numeric literal

Let me know if this helped you and/or if you still would like to discuss further supporting names like this 😃

Thanks for suggestion, it works great.

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

Successfully merging this pull request may close these issues.

3 participants