I’m a lazy coder by nature, so would like to know that there’s a lib out there that does the following before I write on:
var parser = PathParser('/{first}/{last}');
var actual = parser.parse('/fred/flintstone');
assertEquals({"first":"fred","last":"flintstone"}, actual);
The first string specifies a pattern, and the second extracts the relevant values and stores them in an object with keys corresponding to those in the pattern.
I’ve found the standard that does the expansion, but not the generation of the JSON Object.
You want to extract an array of keys from your first string and extract an array of values from the latter, where the value is preceded by a certain pattern and followed by a certain pattern.
There isn’t an existing library that does this, but I have written an implementation. You can find a live demonstration here.