Skip to content

Instantly share code, notes, and snippets.

@hhua
Forked from loriopatrick/q.js
Created February 15, 2017 01:01
Show Gist options
  • Save hhua/b7899b1980b7a0d25f8927538be01ec5 to your computer and use it in GitHub Desktop.
Save hhua/b7899b1980b7a0d25f8927538be01ec5 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