Skip to content

Instantly share code, notes, and snippets.

@hn3000
Created February 16, 2017 07:08
Show Gist options
  • Save hn3000/98ecc891c5588de6445bbe28016d78ad to your computer and use it in GitHub Desktop.
Save hn3000/98ecc891c5588de6445bbe28016d78ad to your computer and use it in GitHub Desktop.
tweetable JSON Pointer Implementation in modern JavaScript
/**
* 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