Skip to content

Escape dot in keypath

Jeeeyul Lee edited this page Jan 23, 2015 · 1 revision

Sometimes property name may can contains . character.

var fixture = {
  "bar.foo" : {
    "zar" : "test",
    "aaa.bbb" : "aaa.bbb"
  }
};

Using double dots

_(fixture).valueForKeyPath("bar..foo.zar");  ==> "test"
_(fixture).valueForKeyPath("bar..foo.aaa..bbb");  ==> "aaa.bbb"

Using Brackets

_(fixture).valueForKeyPath("['bar.foo']['aaa.bbb']");  ==> "aaa.bbb"
Clone this wiki locally