Created
February 16, 2017 07:08
-
-
Save hn3000/98ecc891c5588de6445bbe28016d78ad to your computer and use it in GitHub Desktop.
tweetable JSON Pointer Implementation in modern JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* p is pointer | |
* o is object | |
* returns value pointed at by p or undefined | |
*/ | |
(p,o) => p.split("/").slice(1).map(s => s.replace(/~1/g,'/').replace(/~0/g,'~')).reduce((o,k) => o&&o[k], o) | |
( https://twitter.com/hn3000/status/744970555883925504 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment