Skip to content

Instantly share code, notes, and snippets.

@loriopatrick
Last active February 15, 2017 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save loriopatrick/414cc06bd091bb03a1735a169d4847d1 to your computer and use it in GitHub Desktop.
Save loriopatrick/414cc06bd091bb03a1735a169d4847d1 to your computer and use it in GitHub Desktop.
var a = "[\"test\", \"hello\", [\"world\", \"speak\", 3, [\"apple\"], 18], [\"foo\", \"bar\", [2, 3, 4], [2, 1], \"53\"]]";
var b = "{ \"item\": [2, 3, { \"foo\": \"bar\", \"test\": { \"run\": [5, 4, 8] } }, { \"test\": \"yes\" } ] }";
// extract(a, "0") returns "test"
// extract(a, "3.2.0") returns 2
// extract(b, "item.2.foo") returns "bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment